in reply to Re: RegEx: How to negate more than one character?
in thread RegEx: How to negate more than one character?

thanks... but I am looking for the particular negation to be part of a much more complex overall regular expression... i.e., how can i do the negation within the expression itself, rather than relying on !~?

What I am trying to do is match outermost <% ... %> "brackets" while also handling possible internal pairs of my own unique bracketing system:

$re = qr{\<\%(?:(?>[^(\<\%|\%\>)]+)|(??{$re}))\%\>};

I guess what I am looking for is a replacement to the [^(\<\%|\%\>)]+ part above (unless that is correct).

Replies are listed 'Best First'.
Re^3: RegEx: How to negate more than one character?
by jettero (Monsignor) on Mar 25, 2007 at 23:34 UTC

    You can proably use a negatively asserted look ahead: $str =~ m/$pattern(?!ab|cd)$morepattern/;. It is a zero-width pattern, but it might do what you want. It's about half-way through perlre.

    -Paul