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


Reply via email to