[Pdx-pm] regex & phone numbers...

Christian Brink cb at onsitetech.com
Thu Jul 25 13:56:02 CDT 2002


You may want to look at Number::Phone::US
http://search.cpan.org/doc/KENNEDYH/Number-Phone-US-1.3/lib/Number/Phone/US.
pm

Christian Brink
CTO
ONSITE! Technology
www.onsitetech.com
503.233.1418
cb at onsitetech.com

Taking e-Business and Internet Technology To The Extreme!





> -----Original Message-----
> From: pdx-pm-list-admin at mail.pm.org
> [mailto:pdx-pm-list-admin at mail.pm.org]On Behalf Of Kari Chisholm
> Sent: Thursday, July 25, 2002 10:23 AM
> To: pdx-pm-list at pm.org
> Subject: [Pdx-pm] regex & phone numbers...
>
>
>
> Hey all...
>
> Now that all that madness is past...  I've got another regex stumper.
>
> I want to clean up phone numbers that people submit in a form.  They
> could come in all kinds of ways, like...
>
> (503) 123-4567
> 503.123.4567
> (503)-123-4567
> 123-4567
> 503 123 4567
> 503-123-4567 ext. 89
> 123-4567 ext. 89
> 503-123-4567-mom's house
>
> I want to convert the actual seven- or ten-digit phone number part to
> just xxx-xxx-xxxx.  I also want to leave alone anything that comes
> after that - which is obviously the tough part.  The logic should be
> basically this: just process through the number left to right,
> grabbing the first seven or ten numbers, then reformat those and tack
> on whatever's left.  The challenge is figuring out when it's a
> seven-digit or a ten-digit number.
>
> I've conceptualized any number of highly complex and idiotic ways of
> doing this.  I'm just wondering if there's a simpler regex approach to
> this...  Any ideas?
>
> -kari.
> _______________________________________________
> Pdx-pm-list mailing list
> Pdx-pm-list at mail.pm.org
> http://mail.pm.org/mailman/listinfo/pdx-pm-list




More information about the Pdx-pm-list mailing list