0

Hi,

I've this script that takes care of picking phone number in standard format - xxx-xxxx, further i would like it to pick phonenumber even without hypen - xxxxxxx. How can i do that?

foreach $number (@numbers)
{
if ($number =~ m/(^\d{3}-\d{4}$)/)
{
push @results, $number;
}
}

Thanks, Prince

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jcubic
0

Hi,

I've this script that takes care of picking phone number in standard format - xxx-xxxx, further i would like it to pick phonenumber even without hypen - xxxxxxx. How can i do that?

foreach $number (@numbers)
{
if ($number =~ m/(^\d{3}-\d{4}$)/)
{
push @results, $number;
}
}

Thanks, Prince

It is simple.I understood that you need to match both telephone numbers format such as xxx-xxxx and xxxxxxx.The following script will do the job for you.

foreach $number (@numbers)
      {
      if ($number =~ m/(^\d{3}-\d{4}$)/ || $number=~/(^\d{7}$)/)
      {
      push @results, $number;
      }
      }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.