We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
'''
(?=(?:.\d.){3,}) => This is a lookahead to check that the string contains at least 3 digits (0-9).
(?=(?:.[A-Z].){2,}) => This is a lookahead to check that the string contains at least 2 Uppercase letters (A-Z).
(?!.(.).\1) => ensure that no character repeats.
'^', '$' [a-zA-Z0-9]{10} => This part matches exactly 10 alphanumeric characters.
'''
import re
for _ in range(int(input())):
print("Valid" if re.match(r"^(?=(?:.\d.){3,})(?=(?:.[A-Z].){2,})(?!.(.).\1)[a-zA-Z0-9]{10}$", input()) else "Invalid")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Validating UID
You are viewing a single comment's thread. Return to all comments →
''' (?=(?:.\d.){3,}) => This is a lookahead to check that the string contains at least 3 digits (0-9). (?=(?:.[A-Z].){2,}) => This is a lookahead to check that the string contains at least 2 Uppercase letters (A-Z). (?!.(.).\1) => ensure that no character repeats. '^', '$' [a-zA-Z0-9]{10} => This part matches exactly 10 alphanumeric characters. ''' import re
for _ in range(int(input())): print("Valid" if re.match(r"^(?=(?:.\d.){3,})(?=(?:.[A-Z].){2,})(?!.(.).\1)[a-zA-Z0-9]{10}$", input()) else "Invalid")