>>>>> "MJB" == Matthew J Brooks <[EMAIL PROTECTED]> writes:
MJB> (555) 555-5555
MJB> 555-555-5555
MJB> 555.555.5555
MJB> 555 555-5555
MJB> ]
MJB> I'd like to stip out the usual garbage that a user would enter so
MJB> I can then reformat it. [Actually it'll be reformatted when it
MJB> comes out of the database... wouldn't want to waste any precious
MJB> bytes on formatting :)]
MJB> What I'd like to know is can anyone come up with something less ugly than
MJB> this?
MJB> $phone =~ s#(\(|\)|-|\.| )##g;
you need to learn about character classes. this is better and faster as
well:
s/[(). -]//g ;
you can make that more efficient with:
s/[(). -]+//g ;
or even faster with:
tr/(). -//d ;
and it also depends on how strictly you want to filter out garbage.
s/\D+//g ;
will strip out all non-digits.
so will this and it is faster:
tr/0-9//cd ;
uri
--
Uri Guttman --------- [EMAIL PROTECTED] ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com