Mobile number regular expression in the python

technical talkiess
0

 Regular expression task:- import re


str = "+91-085-550-4291 +91-055-569-8891 +91-055-568-0680 +91-055-584-7375 +91-085-558-9140 +91-055-574-7936 +91-055-541-2960 +91-055-563-2857 +91-055-522-8601 +91-055-569-7121 +91-055-521-6613 +91-055-579-7405 +91-055-508-7860 +91-045-558-5577 +91-055-525-1135 +91-015-550-7840 +91-055-544-1467 +91-055-576-4916 +91-055-589-5050 +91-055-557-6831 +91-055-557-5695 +91-055-538-1883 +91-055-577-4211 +91-055-521-6824 +91-055-502-8692 +91-005-552-9958 +91-085-555-2630 +91-035-551-4408 +91-025-558-0443 +91-055-503-0044 +91-055-558-2072 +91-055-597-9412 +91-055-503-1585 +91-005-554-1746 +91-055-510-6605 +91-075-550-2353 +91-035-558-7567 +91-055-599-5638 +91-055-534-8059 +91-055-564-4962"


pattern = r'\+91-(\d{3})-(\d{3})-(\d{4})'


# Find all matches

matches = re.findall(pattern, str)


# Print the matches

for match in matches:

    print(f"+91-{match[0]}-{match[1]}-{match[2]}")
Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)