Search
Other ReReplacer questions
Forum

Phone number formatting 15556667777 to 1-555-666-7777

Gateway Community College's Avatar Gateway Community College
I have data that is imported that does not have phone numbers formatted. Right now they show up like this example: 15556667777

I would like to use ReReplacer to format the phone numbers correctly 1-555-666-7777. Can this be done? I was able to get it to partially work since the area code is standardized but the prefix and last 4 digits are different. How can I make this work?

My partial attempt gets me this far 1-555-6667777. I need to be able to put something in rereplacer that would take the next 3 digits, whatever they may be and then render a dash after to break up the number.

What would be the best way to handle this? Thanks for your efforts!
Peter van Westen's Avatar Peter van Westen ADMIN
You can do something like this. All do the same thing, just a different syntax:
1555([0-9][0-9][0-9])([0-9][0-9][0-9])
1555([0-9]{3})([0-9]{3})
1555(\d{3})(\d{3})
Then replace with:
1-555-\1-\2
Please post a rating at the Joomla! Extensions Directory
Gateway Community College's Avatar Gateway Community College
Thank you for the quick reply. It worked perfectly! Now I have a question for DB Replacer... 🙂 see you on that forum!
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription