|Inverse grep email@example.com (glen herrmannsfeldt) (2011-06-08)|
|Re: Inverse grep cfc@shell01.TheWorld.com (Chris F Clark) (2011-06-12)|
|Re: Inverse grep firstname.lastname@example.org (Tony Finch) (2011-06-13)|
|Re: Inverse grep email@example.com (2011-06-14)|
|Re: Inverse grep firstname.lastname@example.org (2011-06-15)|
|Re: Inverse grep email@example.com (Paul Wankadia) (2012-05-28)|
|From:||Paul Wankadia <firstname.lastname@example.org>|
|Date:||Mon, 28 May 2012 07:50:26 -0700 (PDT)|
|Posted-Date:||28 May 2012 14:49:44 EDT|
On Jun 9 2011, 9:01 am, glen herrmannsfeldt <email@example.com>
> I suppose this is a strange question, but I was wondering if
> there was ever something like an inverse grep. That is,
> match a string against a file full of regular expressions.
> Now, one could just read the file, compile the regex one at
> a time, and do the match, but maybe there is another way.
The best way to match lots of regular expressions is not to match lots
of regular expressions. :)
In a nutshell, extract the fixed substrings of the regular
expressions, identify which of the fixed substrings (if any) are
present in the input string and determine which of the regular
expressions (if any) are worth trying to match.
The RE2 library includes this functionality, but you will need to BYO
Aho-Corasick implementation. Refer to http://code.google.com/p/re2/source/browse/re2/filtered_re2.h.
Return to the
Search the comp.compilers archives again.