sgrover at open2space.com
Wed Aug 12 02:31:02 PDT 2009
I'm working on a php migration routine where I need to take a list of
phone numbers, which may or may not be properly entered, then format
them into a a common format.
To do this I have found a routine
use a regular expression to find the elements of the number. The
regular expression is:
In my case, if the number doesn't fit the usual patterns, I just return
the original value. (cleaning up the data while migrating, where possible)
This works well thus far, unless the number starts with the country code
(i.e. "1-403-111-2222"). In these cases I end up with a number
formatted as "(140) 311-1222 x.2". So I need to modify the regex to
handle the country code.
I've tried this:
(assuming I only ever see the country code of "1") But this doesn't
Anyone more familiar with regular expressions have any suggestions?
Thanks bunches. I'll happily post my full format function once I get it
working properly, should anyone need it...
More information about the clug-progsig