Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: regex grouping issue

by Velaki (Chaplain)
on Sep 01, 2006 at 10:40 UTC ( [id://570747]=note: print w/replies, xml ) Need Help??


in reply to regex grouping issue

Something you might wish to consider is the restructuring of the logic to take advantage of DeMorgan's Laws, which I found myself using the other day on a particularly funky regex at work.

Essentially, DeMorgan's Laws in my own words are

DeMorgan's Laws:
The compliment of a conjunction is the disjunction of the compliments.
and
The compliment of a disjunction is the conjunction of the compliments.

In other words, not(P and Q) = (not-P or not-Q), et vice versa.

In my application, rather than using alternate lists of certain characters with positive lookarounds, I looked for the match text to have none of the characters with the negative lookarounds. (Which is an "AND" condition, and much easier to perform in my case.)

Hope this helped a little,
-v.

"Perl. There is no substitute."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-28 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found