Exp14-Python
Exp14-Python
SPECIAL CHARACTERS
\A – Returns a match if the specified characters are at the beginning of the string
\b – Returns a match where the specified characters are at the beginning or at the end of a word
\B – Returns a match where the specified characters are present, but NOT at the beginning or at
end of a word.
PROGRAMS:
Write a Regular Expression to represent all 10 digit mobile numbers
Rules:
1. Every number should contain exactly 10 digits
2. The first digit should be 7 or 8 or 9
password validation:
import re
def validate_password(password):
# define our regex pattern for validation
pattern = r"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$"
# We use the re.match function to test the password against the pattern
match = re.match(pattern, password)
password1 = "StrongP@ssword123"
password2 = "weakpassword"
print(validate_password(password1))
print(validate_password(password2))