Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^2: Matching against list of patterns

by Eyck (Priest)
on Sep 16, 2004 at 13:42 UTC ( #391440=note: print w/replies, xml ) Need Help??

in reply to Re: Matching against list of patterns
in thread Matching against list of patterns

This is very nice, but this works well with terms, not that well with regular expressions (ie, not 'foo' but something like 'f[o|O]{1,3}' instead).

Also, this solves little because this only tells me that my line matches one of my patterns.. that is great, but the problem here is finding WHICH re it matches.

I look at your answer, and I think I'm not clever enough to extend this kind of idea to those requirements.

And another thing, how flexible and scalable are perl's res, what happens when there's 1000s of ~40 chars long REs ganged together, will regexp engine/optimizer sort through that?

Replies are listed 'Best First'.
Re^3: Matching against list of patterns
by tachyon (Chancellor) on Sep 16, 2004 at 23:00 UTC

    Remove the map quotemeta and you can use REs to your hears delight. The only issue is then extra | in those REs. My example captures the physical match. It is a simple task to map that back to the pattern (or patterns) that match that if required. The benchmark at Re^2: Matching against list of patterns shows a full order of magnitude speed improvement so the optimiser does OK.



      Note that that benchmark is against the code that still does the whole 'foreach' thing, only in different way.

      I'm sorry, but I don't understand how can I accomplish this simple task of mapping 'physical match back to the pattern or patterns that match'.

      This is the task that we're trying to accomplish at first place, so how is it 'simple' if after a bunch of lines of ingenious code we reduce the problem to itself?

      Either I'm missing something, or I described the problem in confusing way?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2020-11-24 18:23 GMT
Find Nodes?
    Voting Booth?

    No recent polls found