Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- pattern = r'(?P<first_symbols>U[\$])(?P<username>[A-Z][a-z]{2,})(?P=first_symbols)(?P<second_symbols>P[\@][\$])(?P<password>[A-Za-z]{5,}[0-9]{1,})(?P=second_symbols)'
- n = int(input())
- registration = 0
- for _ in range(n):
- text = input()
- matches = list(re.finditer(pattern, text))
- if len(matches) > 0:
- for match in matches:
- print(f'Registration was successful')
- print(f'Username: {match.group("username")}, Password: {match.group("password")}')
- registration += 1
- else:
- print('Invalid username or password')
- print(f'Successful registrations: {registration}')
Add Comment
Please, Sign In to add comment