Re: Help with regex
[email protected] (David Rigaudiere) Thu, 13 Aug 2009 19:09:23 +0200
| Newsgroups | perl.fwp |
|---|---|
| Message-ID | <[email protected]> |
Hi, Perhaps I misunderstood the problem but it seems simple with tr///; Based on this layout = http://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Mobile_phone_keyb= oard.svg/559px-Mobile_phone_keyboard.svg tr/abcdefghijklmnopqrstuvwxyz/22233344455566677778889999/; # =20 should do the job (case-sensitive) Regards. David "Sniper" Rigaudiere On 13 ao=FBt 09, at 18:58, [email protected] wrote: > Seems like this could be fun/golf > > ----- Forwarded by Andy Bach/WIWB/07/USCOURTS on 08/13/2009 11:57 AM =20= > ----- > > > I am using Active Perl 5.8.8. and Perl Dev Kit 7.0. > > I'm writing some code that standardizes the format of phone numbers =20= > in a > database because users have entered them in every way imaginable. > > Anyway, some of the phone numbers look like this: > > 800-69-VORTEX > > ...where the user has entered alpha characters instead of numbers. My > first thought was to use a hash to do the translation, like this: > > %alpha2num =3D > ( > 'A' =3D> '2', > 'B' =3D> '2', > 'C' =3D> '2', > 'D' =3D> '3', > . > . > . > > ...but since the rest of the routine uses only regular expressions, I > thought that it would be nice if this type of translation could be > accomplished with a regex. > > I have not been able to think of a way, but I thought I would put it =20= > to > the list to see if anyone else has done this before. > > Barry Brevik > _______________________________________________ > ActivePerl mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs >