|P is for Practical|
Simple Regexby sevrin (Initiate)
|on Apr 08, 2002 at 17:00 UTC||Need Help??|
sevrin has asked for the
wisdom of the Perl Monks concerning the following question:
I'm new to Perl, and am under the gun to get something figured out. If you'd like to increase your karma, help a novice out.
I need to parse phone numbers from a database. Since there was no input validation in the first place, all kinds of crazy things are in there. To wit:
Here's where it gets fun:
And so on.
My database has a table for phone numbers which has, among other fields, one for the number (tbl_phone.number), and one for the extension (tbl_phone.extension). It seems like what I want to do to grab this data is to put the first 7 things that are digits into $1, and anything that follows that is a digit into $2. This allows me to stuff $1 into tbl_phone.number using a standardized format, as well as putting $2 into tbl_phone.extension with numerals only.
The trouble is that I do not have much experience with regular expressions, so I am reading the camel and ram books to figure it out.
Thanks in advance. I really appreciate the help./Scott