PHP3-finding square brackets with ereg

From: Date: Sat, 22 Jul 2000 16:15:16 +0000
Subject: PHP3-finding square brackets with ereg
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-7696@lists.php.net to get a copy of this message
I can't find instances of square brackets in a string under all conditions. for example: the expression below will find the left bracket, however if I make the $excludeChars="\[\]" it will not find either bracket in the example regardless of which bracket is in the example. Like wise "\]" will not find the right bracket...however, "\[" will find the left bracket. I have no idea what is going on. $excludeChars="\["; $text="when in t[he course of human events"; if(ereg("([$excludeChars])",$text)){ Print("bad chara\n"); } else { Print("ok to use"); } I checks docs, my ref book, I've looked for examples and nothing....any help or pointers to info appreciated. ken

« previous php.general (#7696) next »