in reply to Simple Regex
You love "5", don't you? :)
I'd probably filter all non-alphanumerics, and then split on any string of letters.
while (<DATA>) { chomp; tr/A-Za-z0-9//cd; my ($number, $extension, $overflow) = split /[A-Za-z]+/; if ($overflow) { warn "Don't know how to handle number '$_'.\n"; next; } print "Number: $number"; print ", extension: $extension" if defined $extension and length $ +extension; print "\n"; } __DATA__ (555) 555-5555 555.555.5555 555-555-5555 (555)555.5555 (555) 555-5555 x.555 555.555.5555 Ext. 555 555-555-5555 ext.555
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re2: Simple Regex
by dragonchild (Archbishop) on Apr 08, 2002 at 17:16 UTC | |
by Juerd (Abbot) on Apr 08, 2002 at 17:33 UTC | |
by demerphq (Chancellor) on Apr 08, 2002 at 17:53 UTC | |
by Juerd (Abbot) on Apr 08, 2002 at 18:05 UTC | |
by extremely (Priest) on Apr 08, 2002 at 18:16 UTC | |
|
Re x 2: Simple Regex
by Sweeper (Pilgrim) on Apr 08, 2002 at 20:09 UTC |