Sichanov

match phone numbers

Nov 23rd, 2021 (edited)
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. import re
  2. numbers = input()
  3. pattern = r"\+359-2-\d{3}-\d{4}\b|\+359 2 \d{3} \d{4}\b"
  4.  
  5. print(', '.join(re.findall(pattern, numbers)))
  6.  
  7. ==============================================
  8. import re
  9.  
  10. numbers = input()
  11. pattern = r'\+359(-|\s)2(\1)[0-9]{3}(\1)[0-9]{4}\b'
  12.  
  13. matches = re.finditer(pattern, numbers)
  14.  
  15. for match in matches:
  16.     print(match.group())
  17.  
  18.  
Add Comment
Please, Sign In to add comment