-1

Need a regex that can sift through walls of texts in excel and pick up numbers. Each cell in excel sheet has at least 200-1500 characters with lots of numbers in them so i can't use [^0-9\n] as it simply places all digits together

I need a regex that can detect these phone number patterns and remove everything else

xxx-xxx-xxxx
xxxxxxxxxx
+xxx+xxx+xxxx+

Basically, where the + (plus) sign is, there can be ANY special characters including space key or letter that can be found in the keyboard or out if possible. Example

555a451%6454
555/444-1211<
5554445552
15424331336
1-524l654-3211
(424) 525-5455
(424) 5424522
Etc

Please help.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

1

Try this:

[a-z\%\/\-\(\)\s]?\d{3}[a-z\%\/\-\(\)\s]?\d{3}[a-z\%\/\-\(\)\s]?\d{4}[a-z\%\/\-\(\)\s]?

[a-z\%\/\-\(\)\s] this part is allowed char that means your special char.

live demo

Ahosan Karim Asik
  • 3,219
  • 1
  • 18
  • 27
  • 1
    thanks, but now when i replace all only the above regex strings are removed. anyway to remove all text besides the phone numbers? – John Steiner Jan 07 '15 at 22:46