Please extract all phone numbers from this file, NOW!

<<<< ^^^^^ >>>>
phones.txt
phones.awk
Larry Lounge, H: 213-555-5432, W: (818) 555-1234
My social security number is 555-55-5555
Larry's Valley Chateau: (818) 555-1234
Larry's pager is (818)555-9876
Orlando Lakes, acct# 323x555-1407, phone 555-5644
Charlie Chan from Chicago is at (312)555-1212
BEGIN {pat=\
"(\\({0,1}[0-9]{3}\\){0,1} {0,1}-{0,1} {0,1}){0,1}[0-9]{3}-[0-9]{4}"
}
{
line=$0;
match(line,pat)
while(RLENGTH > 0)
{
print substr(line, RSTART, RLENGTH)
line=substr(line, RSTART+RLENGTH)
match(line,pat)
}
}

From command line

awk --posix -f ./phones.awk phones.txt

<<<< ^^^^^ >>>>

 
 
 
 
Copyright (C) 2001, 2005 by Steve Litt, you can freely distribute unmodified copies if this copyright notice and disclaimer are intact.  This material originally appeared on Troubleshooters.Com.

This presentation has no warranty, express or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the presentation is with you. Neither the author nor those who show the slideshow are responsible for any damage caused by errors, omissions, or anything else relating to this slideshow.
 

6.html

Exit Slideshow