Advertisement
JagadeeshUndavalli

regex

Sep 20th, 2022
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import re
  2. pattern = "^[456][0-9]{15}|^[456][0-9]{3}\-[0-9]{4}\-[0-9]{4}"
  3. for i in range(int(input())):
  4.     stg = input()
  5.     rstg = stg.replace("-","")
  6.     falsePattern = r"([0-9])\1\1\1"
  7.     print(re.findall(re.findall("[ _]",stg)))
  8.     if re.search(pattern,stg) and not(re.search(falsePattern, rstg)) and not(re.search("[ _]",stg)):
  9.         print('Valid')
  10.     else:
  11.         print('Invalid')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement