I guess you can do it also as:
([1-9]{3})[1-9]{3}-[1-9]{4}
cheers,
--t.
On Tue, 19 Mar 2002, Kris Vose wrote:
> How would you write a regular expression that defines a phone number: ex.
>(123)123-1234.
>
> In other words how would you check to see if there were three numerics surrounded by
>(), then three numerics with a "-", then four numerics.
>
>
> This is what I have so far as a regular expression.
>
> ^[(000-999)]+[000-999\-]+[0000-9999]+$
>
> I am using this in an if statement like this:
>
> If (!eregi("^[(000-999)]+[000-999\-]+[0000-9999]+$", $PHONENUMBER)
> {
> echo "This phone number is not valid";
> }
>
>
> Any help is appreciated.
>
> Kris Vose
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php