RE: [PHP] regex for cleaning up username

2001-07-22 Thread Dave

Am partially successfull after taking a further look into things.  the following
(while ugnly) correctly catches everything except the \ character for some
reason.  ideas?

if(preg_match(/['.' ,!@#$%\^*()+=\/\\:;?|]/',$MyString)){
# echo error, character found
}

-Original Message-
From: Jack Dempsey [mailto:[EMAIL PROTECTED]]
Try searching for anything that's not a word character:
if(preg_match(/\W/,$mystring))
that should return true if it matches anything except for a letter,
number, or _...

Will likely switch to that syntax for brevity sake.

your regex didn't work because you didn't use /'s at the beginning and
end of your regex...

caught this one after further review of the regex documentation


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] regex for cleaning up username

2001-07-22 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Dave) wrote:

 Am partially successfull after taking a further look into things.  the 
 following
 (while ugnly) correctly catches everything except the \ character for some
 reason.  ideas?
 
 if(preg_match(/['.' ,!@#$%\^*()+=\/\\:;?|]/',$MyString)){
   # echo error, character found
 }

Try four backslashes instead of two:

preg_match(/['.' ,!@#$%\^*()+=\/:;?|]/',$MyString)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]