Validating UID - Hacker Rank Solution
(.*[A-Z]){2,}
.* matches any character (except for a newline).
[A-Z] matches a single character present in the range between A and Z (case sensitive).
(.*[0-9]){3,}
.* matches any character (except for a newline).
[0-9] matches a single character present in the range between 0 and 9 (case sensitive)
.*(.).*\1+.*
.* matches any character (except for a newline).
\1+ matches the same text as the most recently matched by the 1st capturing group.
.* matches any character (except for a newline).
[A-Z] matches a single character present in the range between A and Z (case sensitive).
(.*[0-9]){3,}
.* matches any character (except for a newline).
[0-9] matches a single character present in the range between 0 and 9 (case sensitive)
.*(.).*\1+.*
.* matches any character (except for a newline).
\1+ matches the same text as the most recently matched by the 1st capturing group.
import re for i in range(int(raw_input())): N = raw_input().strip() if N.isalnum() and len(N) == 10: if bool(re.search(r'(.*[A-Z]){2,}',N)) and bool(re.search(r'(.*[0-9]){3,}',N)): if re.search(r'.*(.).*\1+.*',N): print 'Invalid' else: print 'Valid' else: print 'Invalid' else: print 'Invalid'
No comments:
Post a Comment