Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
public:computer:regexp [2021/12/17 17:31] – alex | public:computer:regexp [2023/01/01 00:58] (current) – [선택, 그룹, 역참조] alex | ||
---|---|---|---|
Line 70: | Line 70: | ||
==== 참조 그룹 ==== | ==== 참조 그룹 ==== | ||
- | * 찾고자 하는 내용을 ()로 감싼 후(참조) $1, $2 혹은 \1, \2와 같이 역참조 | + | * 찾고자 하는 내용을 ()로 감싼 후(참조) |
Line 126: | Line 126: | ||
* 서브패턴 ex) (the|The|THE), | * 서브패턴 ex) (the|The|THE), | ||
- | * 그룹 참조와 역참조; \1, $1 | + | * 그룹 참조와 역참조; \1, \$1 |
* 그룹 이름 지정; ?< | * 그룹 이름 지정; ?< | ||
- | * 그룹 이름으로 참조; $+{one}, $+{two} | + | * 그룹 이름으로 참조; |
^ 그룹 이름 지정 구문 | ^ 그룹 이름 지정 구문 | ||
Line 254: | Line 254: | ||
- -가 2개 이상 | - -가 2개 이상 | ||
- >로 닫음 | - >로 닫음 | ||
+ | |||
+ | * < | ||
+ | * 숫자를 제외한 모든 문자 제거; <alert type=" | ||
+ | * 숫자만으로 되어있는 사업자 번호 -> 사업자번호 형식; <alert type=" | ||
+ | * 숫자만으로만 되어있는지 확인; <alert type=" | ||
+ | * 첫글자만 보이게 마스킹; <alert type=" | ||
+ | * Password Validataions (JAVA & TypeScript)< | ||
+ | |||
+ | public static Boolean hasSpecialCharacter(String strPassword) | ||
+ | { | ||
+ | Boolean bHasSpecialCharacter = Pattern.matches(" | ||
+ | |||
+ | if(true == bHasSpecialCharacter) | ||
+ | { | ||
+ | System.out.println(strPassword + " has Special Character." | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | System.out.println(strPassword + " has no Special Character." | ||
+ | } | ||
+ | |||
+ | return bHasSpecialCharacter; | ||
+ | } | ||
+ | |||
+ | public static Boolean isValidPassword(String strPassword) | ||
+ | { | ||
+ | Boolean bValid = Pattern.matches(" | ||
+ | |||
+ | System.out.println(strPassword + ":" | ||
+ | return bValid; | ||
+ | } | ||
+ | |||
+ | public static Boolean hasAlphabet(String strPassword) | ||
+ | { | ||
+ | Boolean bHasAlphabet = Pattern.matches(" | ||
+ | |||
+ | if(true == bHasAlphabet) | ||
+ | { | ||
+ | System.out.println(strPassword + " has Alphabet." | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | System.out.println(strPassword + " has no Alphabet." | ||
+ | } | ||
+ | |||
+ | return bHasAlphabet; | ||
+ | } | ||
+ | |||
+ | public static Boolean hasDigit(String strPassword) | ||
+ | { | ||
+ | Boolean bHasDigit = Pattern.matches(" | ||
+ | |||
+ | if(true == bHasDigit) | ||
+ | { | ||
+ | System.out.println(strPassword + " has Digits." | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | System.out.println(strPassword + " has no Digits." | ||
+ | } | ||
+ | |||
+ | return bHasDigit; | ||
+ | } | ||
+ | |||
+ | public static void testPassword(String strPassword) | ||
+ | { | ||
+ | System.out.println(" | ||
+ | |||
+ | hasAlphabet(strPassword); | ||
+ | hasDigit(strPassword); | ||
+ | hasSpecialCharacter(strPassword); | ||
+ | }</ | ||
+ | function hasAlphabet(strPassword: | ||
+ | const reg = new RegExp(" | ||
+ | const bHasAlphabet = reg.test(strPassword) | ||
+ | |||
+ | if(false === bHasAlphabet) { | ||
+ | console.log(`${strPassword} has no alphabet.`) | ||
+ | } else { | ||
+ | console.log(`${strPassword} has alphabet.`) | ||
+ | } | ||
+ | | ||
+ | return bHasAlphabet | ||
+ | } | ||
+ | |||
+ | function hasDigit(strPassword: | ||
+ | const reg = new RegExp(" | ||
+ | const bHasDigit = reg.test(strPassword) | ||
+ | |||
+ | if(false === bHasDigit) { | ||
+ | console.log(`${strPassword} has no digit.`) | ||
+ | } else { | ||
+ | console.log(`${strPassword} has digit.`) | ||
+ | } | ||
+ | |||
+ | return bHasDigit | ||
+ | } | ||
+ | |||
+ | function hasSpecialCharacter(strPassword: | ||
+ | const reg = new RegExp(" | ||
+ | const bHasSpecialCharacter = reg.test(strPassword) | ||
+ | |||
+ | if(false === bHasSpecialCharacter){ | ||
+ | console.log(`${strPassword} has no special character.`) | ||
+ | } else { | ||
+ | console.log(`${strPassword} has special character.`) | ||
+ | } | ||
+ | |||
+ | return bHasSpecialCharacter | ||
+ | } | ||
+ | |||
+ | function isValidPassword(strPassword: | ||
+ | const reg = new RegExp(" | ||
+ | const bValid = reg.test(strPassword) | ||
+ | |||
+ | if(false === bValid) { | ||
+ | console.log(`${strPassword} is invalid.`) | ||
+ | } else { | ||
+ | console.log(`${strPassword} is valid.`) | ||
+ | } | ||
+ | |||
+ | return bValid | ||
+ | } | ||
+ | |||
+ | function testPassword(strPassword: | ||
+ | console.log(`Your Password is : ${strPassword}`) | ||
+ | |||
+ | hasAlphabet(strPassword) | ||
+ | hasDigit(strPassword) | ||
+ | hasSpecialCharacter(strPassword) | ||
+ | |||
+ | isValidPassword(strPassword) | ||
+ | |||
+ | }</ | ||
+ | * camelCase to snake_case and MACRO_CASE (JAVA)< | ||
+ | public static String getSnakeCaseFromCamelCase(String strCamelCase) | ||
+ | { | ||
+ | return strCamelCase.replaceAll(" | ||
+ | } | ||
+ | |||
+ | public static String getMacroCaseFromCamelCase(String strCamelCase) | ||
+ | { | ||
+ | return strCamelCase.replaceAll(" | ||
+ | } | ||
+ | </ | ||
+ | * Card Number Validation (TypeScript)< | ||
+ | function validateIBKCEOCard(strCardNumber: | ||
+ | const regDigitsOnly = /(\D+)/gi | ||
+ | const strDigits = strCardNumber.replace(regDigitsOnly, | ||
+ | |||
+ | if (strDigits.length != 16) { | ||
+ | console.log(strCardNumber + ' is invalid card number' | ||
+ | return | ||
+ | } | ||
+ | | ||
+ | console.log(' | ||
+ | |||
+ | const regValidate: | ||
+ | const bValid = regValidate.test(strDigits) | ||
+ | |||
+ | console.log(' | ||
+ | } | ||
+ | </ | ||
+ | |||
Line 269: | Line 433: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
- | * rubular | + | * [[https://rubular.com/ |
Line 291: | Line 455: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | |||