Skip to content Skip to sidebar Skip to footer

Python Regex For Password Validation

I have the following requirement to validate the password with below context at least one digit at least one uppercase letter at least one lowercase letter at least one special ch

Solution 1:

Here is the Regex for at least one digit, one uppercase letter, at least one lowercase letter, at least one special character

import re
password = input("Enter string to test: ")
# Add any special characters as your wish I used only #@$if re.match(r"^(?=.*[\d])(?=.*[A-Z])(?=.*[a-z])(?=.*[@#$])[\w\d@#$]{6,12}$", password):
    print ("match")
else:
    print ("Not Match")

Hope this will Help You...

Post a Comment for "Python Regex For Password Validation"