preg_replace Errors
Posted: Thu May 17, 2007 5:40 pm
its displaying errors such as:
Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 0 in functions.php
and i figure its because some of the charictars, preg_repace is trying to use as modifiers.
how would i fix this?
Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 0 in functions.php
and i figure its because some of the charictars, preg_repace is trying to use as modifiers.
how would i fix this?
Code: Select all
function removebadchars($str)
{
$pats1 = "~.!.@.#.$.%.^.&.*.+.`.-.=.[.].\.'.;.,.{.}.|.:.<.>.?";
$ex1 = explode(".", $pats1);
foreach($ex1 as $patsb)
{
$pats[] = "/".$patsb."/";
$reps[] = "";
}
return preg_replace($pats, $reps, $str);
}