Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Regex AND

by rrwo (Friar)
on Dec 02, 2004 at 12:15 UTC ( [id://411714]=note: print w/replies, xml ) Need Help??


in reply to Regex AND

It looks like you're using a bunch of negative look-ahead assertions to make sure your strings don't start with certain patterns. There are ways to combine them, but you'll have something that's a bit hairy and inefficient. I would rethink what you're parsing a bit, perhaps focusing on positive rather than negative matches for the data you want.

I recall there being a Regexp merging module on CPAN, but I've never used it and cannot find it at the moment. It might be helpful for you.

Check the regular expressions manpage here. I also recommend reading the Mastering Regular Expressions book (O'Reilly information is here and author's web site here) for a tutorial about optimizing regular expressions.

Replies are listed 'Best First'.
Re^2: Regex AND
by gaal (Parson) on Dec 02, 2004 at 12:59 UTC
    That'll be Regexp::Optimizer, which "does, ahem, attempts to, optimize regular expressions" — it performs trie optimization which I believe does not work in this particular case.

      The original author may have been thinking of Regexp::Assemble. I can't say if this module will help with this particular problem.

      Regards,
      Rick
        It will not. Regexp::Assemble matches "everything that any of the individual REs match" (emphasis mine). It makes a disjunction of conditions; the OP wanted a conjunction.
        That module would be for "Regex OR". Interesting module though!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2025-01-23 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (67 votes). Check out past polls.