On Fri, Dec 12, 2003 at 07:54:16PM -0800, Manuel Ochoa wrote:
:
: Why is this test failing?
:
: $data = "A Simple test.";
: If (ereg("^[a-zA-Z0-9\s.\-_']+$", $data)) {
: echo "Valid text";
: }
: else {
: echo "Not valid text";
: }
You can't use the character class "\s" within a range. And you need to
escape a few special characters. The working version should be:
$data = 'A Simple test.';
#if (ereg("^[a-zA-Z0-9\s.\-_']+$", $data))
if (ereg("^[a-zA-Z0-9[:space:]\.\-_']+$", $data))
{
echo "Valid text\n";
}
else
{
echo "Not valid text\n";
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php