Re: [MacPerl-AnyPerl] negative lookahead problem

[email protected] (allan) Sat, 11 Aug 2001 15:26:16 +0200
Newsgroups perl.macperl.anyperl
Message-ID <[email protected]>
thank you both for these solutions which are almost identical and which
feeds further questions ...

bart, i could not get your script to work basicaly because i dont
understand completly whats going on:-)
i mean, i know what i want to put in the $pattern and $replaces
variables but it wont work for me.

ronald's script works out of the box. but again im not sure i understand
why. for instance, what is the difference between | and || (precedence
perhaps?) and why exactly are we using the /e modifier?

<sitenote>
the reason why i took the negative lookahead aproach (which didnt work)
was actually because i gather that such a match doesnt consume so much
memory as a $1, $2 etc match. i dont know if that would ever be a
problem for me but its always nice to have a fast working solution.
</sitenote>

anyway, i got what are asked for.
thanks again
allan




Bart Lateur wrote:
> 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;


Ronald J Kimball wrote:
> s{
>   (<script[^>]*>.*?</script>)   # a script block
>   |
>   ([^\s"'<>%()]+=)([^\s"'<>]+)  # an assignment not in a script block
>  }
>  {
>   $1                            # the script block matched
>   ||
>   qq{$2"$3"}                    # the assignment match
>  }xsieg;
> 
> The easiest way to skip over some block of text is to just match it and
> move on.