[PHP] Re: Looking for an easier regex check...

2002-04-29 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Joshua E Minnie) wrote:

> Does anybody know of a good way to make sure that a string contains ONLY
> certain characters.  I tried using
> ereg("[~`!@#$%^&*(){}-+=|\\/.,<>'\":;\[\]]", $string); but I get parse
> errors.  Besides that I only want the characters A-Za-z0-9_ in $string.  Is
> there is simpler way to ensure this rather than checking to see if any of
> the characters I don't want are in there?

if(preg_match("/\W/",$string))
   {
   echo "Bad characters.";
   }




-- 
CC

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




[PHP] Re: Looking for an easier regex check...

2002-04-29 Thread Henrik Hansen

[EMAIL PROTECTED] (Joshua E Minnie) wrote:

 > Does anybody know of a good way to make sure that a string contains ONLY
 > certain characters.  I tried using
 > ereg("[~`!@#$%^&*(){}-+=|\\/.,<>'\":;\[\]]", $string); but I get parse
 > errors.  Besides that I only want the characters A-Za-z0-9_ in $string.  Is
 > there is simpler way to ensure this rather than checking to see if any of
 > the characters I don't want are in there?

well to correct the parse error you prolly want to escape these chars:

(){} to \(\)\{\}

maybe others, cant see any though.

-- 
Henrik Hansen

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