I want to search all the phone numbers in a text. In this text, I found 4 different formats of phone number:
1234567890
123-456-7890
123 456 7890
(123)456-7890
I wrote a regex pattern and try it in python:
\(?\d{3}[\)\s-]?\d{3}[\s-]?\d{4}
This pattern works, I can use it to search all the phone numbers from the text. But, it also matches some wrong format such as "(1234567890", "123)456-7890" and more wrong formats. I am new to regex. Could you please help me to fix this problem? Thanks sincerely.