I'm having a bit of trouble with regex replacement. I'm trying to convert HTML image tags into CakePHP image code. I can't seem to get it to work.
This is my search string:
<img src="images/([^"]*)" width="([0-9]*)" height="([0-9]*)" alt="" />
I'm trying to use this as a replace string:
<\?php echo \$html\->image\('$1', array\('width' => $2, 'height' => $3, 'alt' => ''\)\); \?>
This doesn't work, as I get a 'malformed replacement string' error. I've tried several variations to the above and found out that this one does work:
<\?php echo image\('$1', array\('width' => $2, 'height' => $3, 'alt' => ''\)\); \?>
But, as you can see I had to drop the $html-> part. What am I missing here? It's driving me nuts. Tried various escaping methods, but all return the malformed string error.