|
|
Le 24/04/2013 09:51, Orchid Win7 v1 a écrit :
> OK, so here's an interesting thought...
>
> I've been looking at string searching algorithms, and regular
> expressions, and generally at pattern matching on data. There are lots
> of ideas about how to find a specific pattern as fast as possible. But
> what I don't see anywhere is how to look for *several* patterns and see
> which one is present. (Especially patterns occurring [or not] at a
> specific location.)
>
> If I'm looking at some data which will contain one of 1,000 possible
> patterns, it sounds like it would be quite inefficient to run 1,000
> different checks on it. I suppose I could try building a decision tree,
> but if most of the patterns are at least half a dozen bytes long,
> there's a danger that tree could become really, really big.
>
> Anyone have any other suggestions?
That's where extended regular expression kick in.
two distinct patterns can be combined as a single one, hence the search
API only need to allow the specification of 1 pattern...
But it solves only half of your problem: it usually won't return the
branch that matches (but rather the start of the match, so after the
search, you still have to identify which sub-pattern was matched, but
that should be "easy", as you do not have to search, only compare)
--
Just because nobody complains does not mean all parachutes are perfect.
Post a reply to this message
|
|