I’m working on a word censor.
I have this text :
$str = "Je connais ce con de conémi".
I want to replace “con” if it’s a whole word, not in a another one.
If I do this :
preg_replace("/\b(con)\b/i", "###", $str);
the result is :
"Je connais ce ### de ###émi".
Conémi has been censored.
This is because of the “é” of conémi.
Just add
uregex modifieror alternative solution is to use PCRE unicode characters:
http://ideone.com/cCoiNp