in reply to Re: Phone Number Regular Expression
in thread Phone Number Regular Expression
Thanks, Roy, that's most helpful!
Of course, it's not quite as simple as all that - I want to substitute a different area code, and make sure to capture things that are formatted slightly differently. So I tested out this substitution, and I'm a little trouble with the scalars:
$_ = "800 555-9998"; s/800( |-|.)555-(?!9999)([0-9]{4})/888$1555-$2/; print $_;
This doesn't seem to work, when I try to include $1 (the separator), though the second scalar comes through fine. I'm guessing I need something to set off $1 from '555'?
Apologies if I'm missing some basic syntax rules; I'm fairly new to perl's regexp lingo.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Phone Number Regular Expression
by japhy (Canon) on Mar 16, 2006 at 17:45 UTC | |
by lev36 (Sexton) on Mar 16, 2006 at 17:55 UTC | |
|
Re^3: Phone Number Regular Expression
by Crackers2 (Parson) on Mar 16, 2006 at 18:17 UTC | |
|
Re^3: Phone Number Regular Expression
by Roy Johnson (Monsignor) on Mar 16, 2006 at 17:47 UTC |