in reply to Phone reg expression
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! |
|---|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Phone reg expression
by jaco (Pilgrim) on Apr 18, 2003 at 17:43 UTC |