in reply to Re: Re: A NOT in regular expressions
in thread A NOT in regular expressions

You are quite right. I should have written:
s/<%(?:[^%]+|%(?!>))*%>/<%$new%>/

Abigail

Replies are listed 'Best First'.
Re: Re: A NOT in regular expressions
by tilly (Archbishop) on May 14, 2003 at 14:51 UTC
    Ilya saved you.

    In older versions of Perl, or in other languages, the above would perform simply pathetically on something like:

    "<%aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +aaaaaaaaaaaaaa"
    However Ilya's optimizations make it perform just fine in recent versions of Perl. :-)
      Yeah, too bad older versions of Perl don't have (?>).

      Abigail

        That wasn't what I was talking about.

        If you have a copy of Perl 5.005_03 sitting around, your code runs perfectly well on it, but on that string the Earth is likely to end before it would finish figuring out that there was no match.