Is there a AND operator for PHP – regular expression.
I’m trying to replace everything from document to ' AND ).
$output = preg_replace('/document.*\'/', '', $output);
Any idea how this can be done?
I’ve tried to find some tutorial for RegEX but I can’t find any good. If you have any good sites or book please give me a link. I googled a lot.
Thanks.
EDIT: Misunderstanding.
This is the code before replaced.
<p>document.write(unescape('
<embed src="XXXXXX" type="application/x-shockwave-flash" wmode="window" width="712" height="475"%.35" allowFullScreen="true" ></embed>
')));</p>
I want to make it look like this:
<p>
<embed src="XXXXXX" type="application/x-shockwave-flash" wmode="window" width="712" height="475"%.35" allowFullScreen="true" ></embed>
</p>
Replaced:
document.write(unescape('
and
')));
What you actually want is to replace two parts, and leave something in between over. To not make it match undesired parts, use explicit character classes:
So it matches anything enclosed in
('and')with varying amounts of the latter.