Related articles |
---|
Inverse grep gah@ugcs.caltech.edu (glen herrmannsfeldt) (2011-06-08) |
Re: Inverse grep cfc@shell01.TheWorld.com (Chris F Clark) (2011-06-12) |
Re: Inverse grep dot@dotat.at (Tony Finch) (2011-06-13) |
Re: Inverse grep torbenm@diku.dk (2011-06-14) |
Re: Inverse grep anton@mips.complang.tuwien.ac.at (2011-06-15) |
Re: Inverse grep junyer@gmail.com (Paul Wankadia) (2012-05-28) |
From: | Paul Wankadia <junyer@gmail.com> |
Newsgroups: | comp.compilers |
Date: | Mon, 28 May 2012 07:50:26 -0700 (PDT) |
Organization: | Compilers Central |
References: | 11-06-015 |
Keywords: | lex |
Posted-Date: | 28 May 2012 14:49:44 EDT |
On Jun 9 2011, 9:01 am, glen herrmannsfeldt <gah@ugcs.caltech.edu>
wrote:
> 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
comp.compilers page.
Search the
comp.compilers archives again.