bl00dt3ars

2

Aug 14th, 2021 (edited)
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. import re
  2.  
  3. 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)'
  4. n = int(input())
  5. registration = 0
  6.  
  7. for _ in range(n):
  8.     text = input()
  9.     matches = list(re.finditer(pattern, text))
  10.     if len(matches) > 0:
  11.         for match in matches:
  12.             print(f'Registration was successful')
  13.             print(f'Username: {match.group("username")}, Password: {match.group("password")}')
  14.             registration += 1
  15.     else:
  16.         print('Invalid username or password')
  17.  
  18. print(f'Successful registrations: {registration}')
Add Comment
Please, Sign In to add comment