▶ 문제 :
▶ 내 답안 : 특수문자제거&대문자&소문자&숫자
regex = "^(?!(?=.*[!@#$^&%*()+=\_\-\[\]\\\/{}|:<>?,. ]).)(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{6,}"
▶ 모범답안1 :
regex = "^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[^\W_]{6,}$"
▶ 모범답안2 :
from re import compile, VERBOSE
regex = compile("""
^ # begin word
(?=.*?[a-z]) # at least one lowercase letter
(?=.*?[A-Z]) # at least one uppercase letter
(?=.*?[0-9]) # at least one number
[A-Za-z\d] # only alphanumeric
{6,} # at least 6 characters long
$ # end word
""", VERBOSE)
▶ 배워야할 부분 ( regex &(and) 조건문 )
그림 : https://regexper.com/
Regexper
regexper.com
실시간 확인 : https://regex101.com/
regex101: build, test, and debug regex
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java. Features a regex quiz & library.
regex101.com
'데이터 - 기본 코드 및 알고리즘 연습 > Codewar' 카테고리의 다른 글
[Codewars] Car Park Escape (0) | 2021.07.27 |
---|---|
[Codewars] validDate Regex (0) | 2021.07.26 |
[Codewars] Sine, cosine and others (0) | 2021.06.30 |
[Codewars] Double Every Other (0) | 2021.06.30 |
[Codewars] Square Every Digit (0) | 2021.06.30 |