I'm working on a profanity filter and have a problem replacing the following variations of hell:
$pattern = array ("/ hell /i","/ hell./i","/hell,/i"
;
$replace = "****";
$output=preg_replace($pattern, $replace, $input);
The problem is that 'shell,' would be filtered to 's****' and 'hell' (if used at the start of the input string) would not be filtered.
Is there a way to protect this and other words like 'shittah' (a.k.a. Acacia tree wood), 'associate', and 'hello' from being unnecessarily filtered?
$pattern = array ("/ hell /i","/ hell./i","/hell,/i"
$replace = "****";
$output=preg_replace($pattern, $replace, $input);
The problem is that 'shell,' would be filtered to 's****' and 'hell' (if used at the start of the input string) would not be filtered.
Is there a way to protect this and other words like 'shittah' (a.k.a. Acacia tree wood), 'associate', and 'hello' from being unnecessarily filtered?