Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [A-Z]+[a-z]+w{1,}
- import re
- pattern_password = re.compile(r'^(?=.*[0-9].*)(?=.*[a-z].*)(?=.*[A-Z].*)[0-9a-zA-Z]{8,}$')
- print(bool(pattern_password.match('absghk4D'))) # True
- print(bool(pattern_password.match('abc123FF'))) # True
- print(bool(pattern_password.match('123ABCac'))) # True
- print(bool(pattern_password.match('abcFF123'))) # True
- print()
- print(bool(pattern_password.match('absghk4D $%#$'))) # False
- print(bool(pattern_password.match(''))) # False
- print(bool(pattern_password.match('bsghk4D'))) # False
- print(bool(pattern_password.match('abc_aaFF'))) # False
- print(bool(pattern_password.match('abcabcac'))) # False
- print(bool(pattern_password.match('ABCDF!@##'))) # False
- ...[0-9a-zA-Z$%#^]{8,}$')
- print(bool(pattern_password.match('$b#FF123'))) # True
- import re
- def test_pwd(pwd):
- '''
- >>> test_pwd("absghk4D")
- True
- >>> test_pwd("absg4D")
- False
- >>> test_pwd("'ra/bsghk4D")
- Traceback (most recent call last):
- ...
- SyntaxError: EOL while scanning string literal
- '''
- def f(exp, word=pwd):
- return bool(re.search(r'{}'.format(exp), word))
- return f('d') and f('[A-Z]') and f('[a-z]') and f('[0-9a-zA-Z]{8,}')
Add Comment
Please, Sign In to add comment