This is the best regexp to check for a valid phone number: /\d/. Seriously, are you going to refuse to accept phone numbers that include extensions, international numbers, and all the other numbers that aren't going to match your regular expression? If that is really what you want, then just remove all the non-numeric characters, and ensure you have 10 or 11 digits left (so you get both 800-123-4567 and 1-800-123-4567). $number =~ s/\D//g; $number =~ /^\d{10,11}$/;
| We're not surrounded, we're in a target-rich environment! |
|---|
In reply to Re: Phone reg expression
by jasonk
in thread Phone reg expression
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |