Formatting phone number

Tool for Search and Replace across multiple files.
Post Reply
User avatar
Aaron Hoyle

Formatting phone number

Post by Aaron Hoyle »

I'm trying to reformat phone numbers across multiple text files. The phone numbers are in the format: (###) ###-#### and I would like them in the format: ##########

I can isolate the phone number(s) with the following "find" string: \([0-9]?[0-9]?[0-9]\) [0-9]?[0-9]?[0-9]-[0-9]?[0-9]?[0-9]?[0-9]?[0-9]

Is there a way to "replace" just the numbers in the text file?

Thanks for your help,
Aaron
User avatar
Aaron Hoyle

Post by Aaron Hoyle »

I kind of got lucky and figured it out on my own. In the event anyone wants to know how I did this:

Find: \((.*)\) (.*)-(.*)
Replace: $1$2$3

Converts to: (xxx) xxx-xxxx to xxxxxxxxxx

Thanks for a great freeware program, it really helped solve a problem for me!
User avatar
DV

Post by DV »

It's just a matter of setting up 'capturing' groups using brackets in the expression, then referencing them in the replace string using $groupno -
ie
Regex: \(([0-9]?[0-9]?[0-9])\) ([0-9]?[0-9]?[0-9])-([0-9]?[0-9]?[0-9]?[0-9]?[0-9])
Replace: $1$2$3

This should do it.

Edit: Just posted this then saw your response. Glad you like TC.
Post Reply