Page 1 of 1

Find/Extract Phone Numbers from multiple files

Posted: Tue Feb 03, 2009 6:14 pm
by liveadvertiser
I have thousands of files in multiple directories.
There are multiple file types such as txt, csv, html and others.

I am looking to extract phone numbers from these files into a single file of just the phone nubmers one per line.

Right now the phone numbers are in multiple areas of long and short lines.

The phone nubmers are all formatted in almost as many ways as a phone number can be formatted for instance:
8885551212
888-555-1212
(888)555 1212
(888) 555-1212
888.555.1212
888 555 1212
1 888 555 1212
1-888-555-1212
etc.
I am only looking for numbers which are usa so that means 10 or 11 digit numbers. If 11 digits then the first number must be a "1" and NOT be FOLLOWED by another "1" or a "0".


Any help on how I can perform this amazing feat with textpad will be much appreciated!

Posted: Tue Feb 03, 2009 8:11 pm
by ben_josephs
Find what: (([0-9]{3}|\([0-9]{3}\))[ .-]?|(1[ .-])[2-9]{3}[ -]?)[0-9]{3}[ .-]?[0-9]{4}

[X] Regular expression
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
I suspect there are other restrictions on the area code.

Posted: Fri Feb 06, 2009 7:41 pm
by liveadvertiser
AWESOME!!!!!!!!!!
THANK YOU SO MUCH!!!!!!!!!!!!!!!!!

That worked great.
It didnt get 100% of the numbers but enough to matter!

Posted: Fri Feb 06, 2009 7:53 pm
by ben_josephs
If you tell us which ones it didn't catch, we can fix it so that it does.