public:computer:regexp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
public:computer:regexp [2022/01/04 18:02] – [References] alexpublic:computer:regexp [2023/01/01 00:58] (current) – [선택, 그룹, 역참조] alex
Line 70: Line 70:
  
 ==== 참조 그룹 ==== ==== 참조 그룹 ====
-  * 찾고자 하는 내용을 ()로 감싼 후(참조) $1, $2 혹은 \1, \2와 같이 역참조+  * 찾고자 하는 내용을 ()로 감싼 후(참조) \$1, \$2 혹은 \1, \2와 같이 역참조
  
  
Line 126: Line 126:
  
   * 서브패턴 ex) (the|The|THE), (t|T)h(e|eir)   * 서브패턴 ex) (the|The|THE), (t|T)h(e|eir)
-  * 그룹 참조와 역참조; \1, $1 +  * 그룹 참조와 역참조; \1, \$1 
   * 그룹 이름 지정; ?<one>, ?<two>   * 그룹 이름 지정; ?<one>, ?<two>
-  * 그룹 이름으로 참조; $+{one}, $+{two}+  * 그룹 이름으로 참조; \$+{one}, \$+{two}
  
 ^  그룹 이름 지정 구문  ^^ ^  그룹 이름 지정 구문  ^^
Line 260: Line 260:
   * 숫자만으로만 되어있는지 확인; <alert type="info"><nowiki>(JAVA) bDigitsOnly = str.matches("^\\d+\$");</nowiki></alert>   * 숫자만으로만 되어있는지 확인; <alert type="info"><nowiki>(JAVA) bDigitsOnly = str.matches("^\\d+\$");</nowiki></alert>
   * 첫글자만 보이게 마스킹; <alert type="info"><nowiki>(JAVA) strMasked = str.replaceFirst("(^\\S)\\S+\$", "\$1*****");</nowiki></alert>   * 첫글자만 보이게 마스킹; <alert type="info"><nowiki>(JAVA) strMasked = str.replaceFirst("(^\\S)\\S+\$", "\$1*****");</nowiki></alert>
-  * Password Validataions<sxh java title:Password Validation for JAVA>+  * Password Validataions (JAVA & TypeScript)<sxh java title:Password Validation for JAVA>
  
     public static Boolean hasSpecialCharacter(String strPassword)      public static Boolean hasSpecialCharacter(String strPassword) 
Line 388: Line 388:
  
 }</sxh> }</sxh>
-  * camelCase to snake_case and MACRO_CASE <sxh java title:camelCase to snake_case and MACRO_CASE>+  * camelCase to snake_case and MACRO_CASE (JAVA)<sxh java title:camelCase to snake_case and MACRO_CASE for JAVA>
     public static String getSnakeCaseFromCamelCase(String strCamelCase)     public static String getSnakeCaseFromCamelCase(String strCamelCase)
     {     {
Line 398: Line 398:
         return strCamelCase.replaceAll("([A-Z])", "_$1").toUpperCase();         return strCamelCase.replaceAll("([A-Z])", "_$1").toUpperCase();
     }     }
 +</sxh>
 +  * Card Number Validation (TypeScript)<sxh typescript title:Card Number Validation Example for TypeScript>
 +function validateIBKCEOCard(strCardNumber: string) {
 +  const regDigitsOnly = /(\D+)/gi
 +  const strDigits = strCardNumber.replace(regDigitsOnly, "")
 +
 +  if (strDigits.length != 16) {
 +    console.log(strCardNumber + ' is invalid card number')
 +    return
 +  }
 +  
 +  console.log('validate IBK CEO Card: ' + strCardNumber + ' => ' + strDigits + '(' + strDigits.length + ')')
 +
 +  const regValidate: RegExp = /^943003|^552103\d+$/g
 +  const bValid = regValidate.test(strDigits)
 +
 +  console.log('is valid? ' + bValid)
 +}
 </sxh> </sxh>
  
  • public/computer/regexp.1641286966.txt.gz
  • Last modified: 2022/01/04 18:02
  • by alex