Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Negating Regexes: Tips, Tools, And Tricks Of The Trade

by Sidhekin (Priest)
on Dec 07, 2006 at 13:58 UTC ( #588318=note: print w/replies, xml ) Need Help??


in reply to Negating Regexes: Tips, Tools, And Tricks Of The Trade

So what tools, tips, and tricks of the trade do you have to share for these rare occassions you need to write a regex that matches everything another regex doesn't?

 /^(?!(?s:.*)$regex)/

:-)

Caveat: Only useful in a boolean context.

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Replies are listed 'Best First'.
Re^2: Negating Regexes: Tips, Tools, And Tricks Of The Trade
by ikegami (Pope) on Dec 07, 2006 at 16:33 UTC
Re^2: Negating Regexes: Tips, Tools, And Tricks Of The Trade
by Limbic~Region (Chancellor) on Dec 07, 2006 at 16:08 UTC
    Sidhekin,
    Very Nice!

    I admit that look around assertions, non-capturing clusters, and local modifiers are not my strong suit so I learned a bit from this one-size-fits-all solution. It would be nice if you forgot you knew how to do that though and shared other examples.

    Cheers - L~R

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2019-07-24 02:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (32 votes). Check out past polls.

    Notices?