Re: regular expression

From: Date: Tue, 19 Mar 2002 17:53:59 +0000
Subject: Re: regular expression
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-89168@lists.php.net to get a copy of this message
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 >

« previous php.general (#89168) next »