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.