Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: RegEx: How to negate more than one character?

by lokiloki (Beadle)
on Mar 25, 2007 at 23:15 UTC ( [id://606499]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://606499]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-25 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found