I have to extract phone numbers from free form of texts.
How can I manage it by using reg-ex in python?
I have found for one in order to extract e-mail addre
This should find all the phone numbers in a given string including international numbers. Taking the example by @buckley, Lets use the string
text="""Matches 3334445555, 333.444.5555, 333-444-5555, 333 444 5555, (333) 444 5555 and all combinations thereof, like 333 4445555, (333)4445555 or 333444-5555. Does not match international notation +13334445555, but matches domestic part in +1 333 4445555."""
re.findall(r'+?(?[1-9][0-9 .-()]{8,}[0-9]', text)
>>> re.findall(r'[\+\(]?[1-9][0-9 .\-\(\)]{8,}[0-9]', text)
['3334445555', '333.444.5555', '333-444-5555', '333 444 5555',
'(333) 444 5555', '333 4445555', '(333)4445555', '333444-5555',
'+13334445555', '+1 333 4445555']
Basically, the regex lays out these rules