Someone called Dermot McGahon said on Wed, Aug 23, 2000 at 08:33:47PM +0100:
> Anyway, I now need to modify the commment stripping regex so that it
> only strips comments when they are not contained with <SCRIPT> and
> </SCRIPT>. I thought that negative lookahead assertion might be the
> way to go so I tried:
>> $document =~ s{(<!--.*?-->)(?!\s*</script>)}{}gim;
>> and
>> $document =~ s{<!--.*?-->\s*(?!</script>)}{}gim;
>
Lookaheads, be they positive or negative, are immediate, so you need to allow
for any stuff between the opening <!-- and the <script> tags.
Just off the top of my head, the way I'd try and do this would be:
$document =~ s/<\!\-\-(?!.*?<\/script>).*?\-\->//isg;
If i didn't include the .*? inside the negative lookahead, it's try to match
the </SCRIPT> tag immedietely after the opening comment.
- DoC
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!