Find/Extract Phone Numbers from multiple files

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
liveadvertiser
Posts: 2
Joined: Tue Feb 03, 2009 6:01 pm

Find/Extract Phone Numbers from multiple files

Post 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!
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
liveadvertiser
Posts: 2
Joined: Tue Feb 03, 2009 6:01 pm

Post by liveadvertiser »

AWESOME!!!!!!!!!!
THANK YOU SO MUCH!!!!!!!!!!!!!!!!!

That worked great.
It didnt get 100% of the numbers but enough to matter!
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

If you tell us which ones it didn't catch, we can fix it so that it does.
Post Reply