regular expression

From: Date: Tue, 19 Mar 2002 17:51:55 +0000
Subject: regular expression
Groups: php.general 
Request: Send a blank email to php-general+get-89166@lists.php.net to get a copy of this message
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 (#89166) next »