The parameter is a string. Check whether it forms a secure password.A password is safe if
- there is at least a lowercase letter in it, and
- there is at least one capital letter in it, and
- there is at least one digit in it, and
- there is at least one special character (+, -, *, /,. or @) in it, and
- it counts at least 8 characters, and
- it has a maximum of 20 characters, and
- there are no three equal consecutive characters in it (eg 'a7XXX @ fda' is invalid because of the XXX), and
- no group of three characters occurs multiple times (eg 'XYZ.1a.XYZ' is invalid because XYZ appears twice).
I tried:
regex = [r'^.{8,20}$', r'[a-z]+', r'[A-Z]+', r'\d+', r'[-+*/.@]', r'(.)(.)(.)(\1\2\3)']return all(re.search(pas, password) for pas in regex)