I have a regex that controls a password so that it contains an upper case, a lower case, a number, a special character and minimum 8 characters.
regex is:
regex_password = r"^(?=.*[a-z])(?=.*[A-Z])(?=.*[\W]).{8,}$"
I use in this function:
def password_validator(password):
#REGEX PASSWORD : minimum 8 characters, 1 lowercase, 1 uppercase, 1 special caracter
regex_password = r"^(?=.*[a-z])(?=.*[A-Z])(?=.*[\W]).{8,}$"
if not re.match(regex_password, password):
raise ValueError("""value is not a valid password""")
return password
However, the use of "²" raises me an error, however, this same regex with a Javascript front-end validation, or on different regex validation site,works.
The problem is possible the ascii, so how can i do for python accept the ascii character in regex ?