in reply to Re: formatted phone number from variable
in thread formatted phone number from variable

good solution, but it doesn't take care of the second case that was mentioned, where the phone number could be 1-234-567-890.

An application I had to make for my office needs to format phone numbers that come in all shapes and sizes... I use this:

$phone =~ s/.*(\d{3}).*(\d{3}).*(\d{4}).*/$1-$2-$3/;

which is JAWTDI, similar to others mentioned here. Of coures, checks and balances for when there are not 10 digits apply.


Jason W.
  • Comment on Re: Re: formatted phone number from variable