I got the following string:
last_name, first_name
bjorge, philip
kardashian, [kghim]
mer#$##Code:menu:51587daa7030e##$#cury some more
data #$##Code:menu:515r4387daa7dsf030e##$#, freddie
im trying to replace the Codes in the middle with the function: 'codeParser' the regex is:
$PC_File = preg_replace_callback("(?=\#\$\#\#).*?(?<=\#\#\$\#)", 'codeParser', $PC_File);
but getting this error:
PHP Warning: preg_replace_callback() : Unknown modifier '.'
You need to wrap your regular expression in delimiters. It's considering ()
to be the delimiters right now, and the .
as a modifier (which is of course invalid).
"/(?=#\\$##).*?(?<=##\\$#)/"
(I'm also pretty sure the #
do not need to be escaped unless you were using them as delimiters)
EDIT: You need \\
to properly escape the $
in double-quotes.