Re: [MacPerl-AnyPerl] negative lookahead problem

[email protected] (Bart Lateur) Fri, 10 Aug 2001 16:31:57 +0200
Newsgroups perl.macperl.anyperl
Organization MediaMind
Message-ID <[email protected]>
On Fri, 10 Aug 2001 00:01:25 +0200, allan wrote:

>i want to do a global replace om a search string _unless_ the string is
>encapsulated in <script></script> tags.

Perhaps you should try out my age-old mechanism of "replacing some
strings by themselves" in order to skip some parts.

	s%(<script.*?>.*?</script>)|($pattern)%$1 || $replace{$2}%isge;

I'm not sure exactly what you want to replace by what, so I've just
taken a hash entry for an example. So it will match the entire "script",
or the string your searching for, and replace it only if it wasn't a
"script".

BTW:

>> (?!.*<\/script>)			#as long as string doesnt end with <...script>

Eh, that's wrong. This will fail whenever there's a "</script>" further
down in the source. That's why only stuff past the last "</script>" is
replaced. (text7 and text8)

-- 
	Bart.