Reply to [PHP] Regular expression. What is wrong?

Your name:

Reply:


Posted by Kostyantyn Shakhov on 10/04/66 11:08

I have to check the phone number. I use some regular expression for
this. The phone number can contain only numbers and characters like
+,-,),( and space. The problem is when I use a Perl-style all works as
intended but when I use a Posix-style I've got the Warning: ereg():
REG_ERANGE and the result is opposite to intended one. What is wrong
in the following?

<?php
$test_phone = "8 (044) 419-0567";

if(preg_match("/^[+]?[\d\-\040\)\(]+$/", $test_phone))
{
echo "valid phone<br />";
}
else
{
echo "not valid phone<br />";
}

if(ereg("^[+]?[0-9\-[:space:]\)\(]+$", $test_phone))
{
echo "valid phone<br />";
}
else
{
echo "not valid phone<br />";
}
?>

--
Best regards,
Kostyantyn Shakhov mailto:shakhov@fresh-design.net

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация