Page 1 of 1

phone numbers various formats

Posted: Wed Nov 07, 2007 7:25 pm
by kleino
I need to eliminate phone numbers from files
I dont always know the format of the number.
Possible formats could be

888-888-8888
(888)-888-8888
(888) 888-8888
888.888.8888
8888888888

I understand that I can do a batch replace with all 5 formats as above. But is there a way to provide the software just one format (e.g. 888-888-8888) and have it find all permutations and delete them?

Also, can you define "regular expression"

and also point to where this coding tutorial can be found so that I can make better use of the program. You provided this to another user:

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
(\(\d+\) \d+-)\d+ ext. (\d+)

Replace with:
$1$2

Re: phone numbers various formats

Posted: Wed Nov 07, 2007 7:51 pm
by kleino
okay, I got it - I understand the regular expressions and the coding

so will the regular expression

.888.888.8888 find all permutations , such as

888-888-8888
(888)-888-8888
(888) 888-8888
888.888.8888
8888888888

Re: phone numbers various formats

Posted: Wed Nov 07, 2007 8:32 pm
by Abacre
The right regular expression describing strictly your case should be:

Search for:
\(*\d{3}[\)\-\. ]*\d{3}[\-\.]*\d{4}
Replace with:
should be empty text if you want to remove phone numbers.

Re: phone numbers various formats

Posted: Thu Nov 08, 2007 7:40 pm
by kleino
since I am unfamiliar with regular expressions, can you show me exactly waht to type in if I want to serach for the phone number 888-888-8888 but I dont know the format.
Thank you

Re: phone numbers various formats

Posted: Thu Nov 08, 2007 10:26 pm
by Abacre
\d means a digit,
\d{3} means exactly 3 digits.

For for 888-888-8888 you should use search for:
\d{3}-\d{3}-\d{4}

Re: phone numbers various formats

Posted: Fri Nov 09, 2007 3:16 am
by kleino
I am sorry, that makes no sense to me. That would search for ANY 10 digit number. What EXACTLY do I type as the search string if I want to search for the phone number

9259359251
(which may exist in the files at 925-935-9251 or 925.935.9251 or (925) 935-9251 or (925)935-9251)

do I type:

9259359251\(*\d{3}[\)\-\. ]*\d{3}[\-\.]*\d{4}

or do I type as the search string

\(*\d{3}[\)\-\. ]*\d{3}[\-\.]*\d{4}9259359251

what EXACTLY do I type as the search string fto find the phone number 9259359251 in whatever format it may exist?

Thank you

Re: phone numbers various formats

Posted: Fri Nov 09, 2007 9:40 am
by Abacre
As I said in my first message you should type EXACTLY the following:
\(*\d{3}[\)\-\. ]*\d{3}[\-\.]*\d{4}

Re: phone numbers various formats

Posted: Sat Nov 10, 2007 3:03 am
by kleino
I need to eliminate SPECIFIC phone numbers, not ALL phone numbers.

what do I type if I ONLY want to eliminate phone number 925-935-9251 and leave all other phone numbers unchanged?

If I use this as my search string \(*\d{3}[\)\-\. ]*\d{3}[\-\.]*\d{4}, wont this replace ALL phone numbers?

Re: phone numbers various formats

Posted: Sat Nov 10, 2007 10:44 am
by Abacre
\(*\d{3}[\)\-\. ]*\d{3}[\-\.]*\d{4} will eliminate all phone numbers.

If you want to eliminate just 925-935-9251 in various formats then you should use the expression:
\(*925[\)\-\. ]*935[\-\.]*9251