Re: Regex for telephone numbers
| From: | Ethan Rosenberg | Date: | Thu, 30 Dec 2010 19:07:39 +0000 |
| Subject: | Re: Regex for telephone numbers | ||
| References: | 1 2 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-47582@lists.php.net to get a copy of this message | ||
At 07:27 PM 12/29/2010, Josh Kehn wrote:
On Dec 29, 2010, at 7:12 PM, Ethan Rosenberg <ethros@earthlink.net> wrote: Dear List - Thank you for all your help in the past. Here is another one.... I would like to have a regex which would validate that a telephone number is in the format xxx-xxx-xxxx. Thanks. Ethan MySQL 5.1 PHP 5 Linux [Debian (sid)] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You can't, phone numbers are more complex then that. You could use \d{3}-\d{3}-\d{4} to match that basic pattern for all numbers though. Regards, -Josh ___________________________ http://joshuakehn.com++++++++++++
Sent from my iPod Josh -I used use \d{3}-\d{3}-\d{4}. It works beautifully!! FYI [to all the list] -- I thank all for their input. I only needed US phones, and I am forcing the user of the form to conform to xxx-xxx-xxxx as the input format. Ethan ++++++++++++