I am trying to extract only US phone numbers from a string.
I looked through web / SO but did not find a suitable solution for my needs.
Honestly, I have 2.5 years of experience in web programming, but I suck at RegEX.
That's just RegEX I wrote (\d{3}+\-\d{3}+\-\d{4}+)
but he only discovers 589-845-2889
Here are the phone numbers I want to extract.
589-845-2889 (589)-845-2889 589.845.2889 589 845 2889 5898452889 (589) 845 2889
Please tell me how I can achieve this skill in one Regex for PHP.
EDIT:
If you feel any other U.S. number format that the user can enter, indicate this as well and include it in RegEX.
PS:
I am actually trying to clear Craiglist, and the user may have posted his phone number in any possible format.
php regex
Umair
source share