Guest User

Untitled

a guest
Jul 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. [A-Z]+[a-z]+w{1,}
  2.  
  3. import re
  4. pattern_password = re.compile(r'^(?=.*[0-9].*)(?=.*[a-z].*)(?=.*[A-Z].*)[0-9a-zA-Z]{8,}$')
  5.  
  6. print(bool(pattern_password.match('absghk4D'))) # True
  7. print(bool(pattern_password.match('abc123FF'))) # True
  8. print(bool(pattern_password.match('123ABCac'))) # True
  9. print(bool(pattern_password.match('abcFF123'))) # True
  10. print()
  11. print(bool(pattern_password.match('absghk4D $%#$'))) # False
  12. print(bool(pattern_password.match(''))) # False
  13. print(bool(pattern_password.match('bsghk4D'))) # False
  14. print(bool(pattern_password.match('abc_aaFF'))) # False
  15. print(bool(pattern_password.match('abcabcac'))) # False
  16. print(bool(pattern_password.match('ABCDF!@##'))) # False
  17.  
  18. ...[0-9a-zA-Z$%#^]{8,}$')
  19.  
  20. print(bool(pattern_password.match('$b#FF123'))) # True
  21.  
  22. import re
  23.  
  24. def test_pwd(pwd):
  25. '''
  26. >>> test_pwd("absghk4D")
  27. True
  28. >>> test_pwd("absg4D")
  29. False
  30. >>> test_pwd("'ra/bsghk4D")
  31. Traceback (most recent call last):
  32. ...
  33. SyntaxError: EOL while scanning string literal
  34. '''
  35. def f(exp, word=pwd):
  36. return bool(re.search(r'{}'.format(exp), word))
  37. 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