2

This is likely the simplest issue ever. But I did not write the code and its not commented. I am just trying to fix it because its causing a lot of issues on my site. Its in the main text parser code.

Error: preg_replace(): Unknown modifier '\' More Complete error: PHP Warning: preg_replace(): Unknown modifier '\' in .../cutout/text/parser.php on line 1192, referer: domain/forums/

Code: http://pastebin.com/k98mpF8n There is a lot of it so this is the simplest way to do it. $text is the parameter. Looks like its a bad word filter but seems to be missing with lots of things. I can't find out what is being passed sorry. Unless you know of a why that I could.

-
$text = preg_replace( '/(^|\W)' . preg_quote( $test ) . '(\W|$)/i', "\\1" . $replace . "\\2", $text );
-

I am sure I am just missing it.

Any help is greatly appreciated. Thanks

1 Answers1

1

preg_replace(): Unknown modifier occurs when $test contains a /.

preg_quote( $test );

should be

preg_quote( $test, '/' );

/ is the PCRE delimiter used in your '/(^|\W)...(\W|$)/i' expression.

PHP PCRE's can have any delimiter, so you have to tell preg_quote() which delimiter is used.
http://php.net/manual/en/regexp.reference.delimiters.php

PaulH
  • 2,918
  • 2
  • 15
  • 31