Help w/ regular expressions for banned words
| From: | Team JUMP | Date: | Sat, 20 Jan 2001 16:42:47 +0000 |
| Subject: | Help w/ regular expressions for banned words | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-35807@lists.php.net to get a copy of this message | ||
$num=count($bannedwords);
for($i=0;$i<$num-1;$i++)
{
$string =
eregi_replace("\b$bannedwords[$i]\b","[censored]",$string);
}
For whatever reason, no word in $bannedwords will match in the string. I've
tested it with simple expressions like "\btest\b" and it will not match the
word "test". Does it have something to do with the 2 "\b"s found in the
code? After removing them, it replaces all instances of $bannedwords, even
in the middle of words, which is not good. Any suggestions?
TIA,
Neal