Re: [PHP] ereg is failing on this simple test

2003-12-13 Thread Eugene Lee
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



[PHP] ereg is failing on this simple test

2003-12-12 Thread Manuel Ochoa
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;
}
 
I'm running PHP 4.34 on a windows pc. This function is new to me, any help would be 
appreciated.


RE: [PHP] ereg is failing on this simple test

2003-12-12 Thread Dave G
 Why is this test failing?
 If (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) {

I'm very new to PHP, so I may be barking up the wrong tree, but what is
that s doing after the slash? I don't know if it's the cause of the
problem, but as far as I know it's superfluous.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php