Inane ereg problem
| From: | Kenneth Bogucki | Date: | Tue, 25 Jul 2000 00:07:03 +0000 |
| Subject: | Inane ereg problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-7975@lists.php.net to get a copy of this message | ||
My problem is this...to prevent users from running a bad search the
below code checks for illegal characters, if it finds them...there is an
error message with a display of illegal chars. The problem is the right
square bracket. If I insert \] into the $excludeChars variable the
rountine ceases to work...no error messages, it just won't find any
errors in the sample text. Can someone explain why the right bracket is
causing so much trouble.
ken
$excludeChars="\[\*\.\-\+\{\}\%\\$\|\#\@";
$text="when in t[he course of human events";
if(ereg("([$excludeChars])",$text)){
Print("bad characters\n");
$letters=implode(" ",explode("\\",$excludeChars));
print($letters);
}
else{
Print("ok to use");
}