Hello!
I am using PHP and preg_replace. I have output from an XSL transformation that I would like to insert into a mysql database. I would like to construct a regular expression that escapes single and double quotes. My data set looks like this:
<escape>Welcome to Barbara's house.</escape>
<escape>"Happy Birthday!" they yelled when she walked in.</escape>
<escape>Oh my, I'm feeling tired.</escape>
I would like to remove the <escape></escape> tags and escape the quotes so the output looks like:
Welcome to Barbara\'s house.
\"Happy Birthday!\" they yelled when she walked in.
Oh my, I\'m feeling tired.
The data set is very big so there's no way to do it manually. I tried a solution using XSLT but was not impressed by the performance. So far I have this expression:
$html = preg_replace("/<escape>(.*?)<\/escape>/", "#1", $html);
echo $html;
But I am completely stumped! If you could show me how to accomplish my goal I would be truly indebted and happy to throw you a few dollars for your time.
Thanks in advance.
Mike