I would like to replace the following:
="Dark4Red"
with
=\"Dark4Red\"
The = sign and double quotations are fixed =”…”
I just need to add slashes before double quotations.
$content = preg_replace('/="[^a-zA-Z#0-9]"/', '=\"[^a-zA-Z#0-9]\"', $line);
The above solution didn’t work. Any idea?
How about
addslashes?That aside, you appear to have not read any of the examples on
preg_replace‘s manual page – if you had, you’d have known that you capture a subpattern (in this case the contents of the quotes) with parentheses and use$1to put them in the replacement string.