How do I write a Perl Script that display lines containing only valid phone numbers anywhere on the line?
Let us assume that (888).888-8888 is a valid number, where 8 could be any number.
So the sample input is
this is nota number
3214235234
(410).977-2132
my num is ((410.222-1231))
test 234 test
Output:
(410).977-2132
my num is ((410.222-1231))
Here is what i HAVE SO FAR
if ($string =~ /^(?:(?:\+?1\s*(?:[.]\s*)?)?(?:\(\s*([.][2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$) {
# is a number
} else {
# is not
}
I think i may have wrong regular expression. Can you please help?