note 60130 added to function.preg-match
| From: | johnatrecaffeinatedd0tc0m at osu1 dot php dot net | Date: | Tue, 27 Dec 2005 16:27:37 +0000 |
| Subject: | note 60130 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100800@lists.php.net to get a copy of this message | ||
Here's a format for matching US phone numbers in the following formats:
###-###-####
(###) ###-####
##########
It restricts the area codes to >= 200 and exchanges to >= 100, since values below these are
invalid.
<?php
$pattern = "/(\([2-9]\d{2}\)\s?|[2-9]\d{2}-|[2-9]\d{2})"
. "[1-9]\d{2}"
. "-?\d{4}/";
?>
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60130
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60130&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60130&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60130&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60130&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60130&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60130&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60130&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60130&report=yes
Search -- http://master.php.net/manage/user-notes.php