I'm working on validating US phone numbers. I have a nice expression that
Regex Coach likes, but causes PHP to reject everything I send. Are there
any glaring differences? I can't figure out what's wrong. Another little
email check works fine, using the code out of Wrox' Beginning PHP.
PhoneCheck.php
<?php
function PhoneCheck($num ber)
{
return ereg("^[(\[]?\d{3}[)-\.\] ]*\d{3}[-\. ]?\d{4}$", $number,
$scrap);
}
?>
My test cases (which passed regex coach, but failed my php form):
123 456 7890
(123) 456-7890
123.456.7890
123-456-7890
Thanks,
-G
Regex Coach likes, but causes PHP to reject everything I send. Are there
any glaring differences? I can't figure out what's wrong. Another little
email check works fine, using the code out of Wrox' Beginning PHP.
PhoneCheck.php
<?php
function PhoneCheck($num ber)
{
return ereg("^[(\[]?\d{3}[)-\.\] ]*\d{3}[-\. ]?\d{4}$", $number,
$scrap);
}
?>
My test cases (which passed regex coach, but failed my php form):
123 456 7890
(123) 456-7890
123.456.7890
123-456-7890
Thanks,
-G
Comment