eregi regular expression error

Reztlaf

New Member
This is the code I am working on\[code\] if(trim($_POST['phone']) == '') { $hasError = true; print "phone number empty"; } else if (!eregi("^\(?[\d]{3}\)?[\s-]?[\d]{3}[\s-]?[\d]{4}\s*$", trim($_POST['phone']))) { // if I am right this should validate all U.S. numbers $hasError = true; print "phone number does not match regular expression"; } else { $phone = trim($_POST['phone']); }\[/code\]I use the number \[code\]555-555-5555\[/code\] and it is catches on the if loop after checking the regular expression and prints the statement "phone number does not match regular expression". I have tested it out at http://regexpal.com/ and it says everything is hunky dory... Any ideas what I am doing wrong?
 
Back
Top