C regexp package that can save compiled expressions?

"John R Levine" <johnl@iecc.com>
13 Aug 2004 17:35:41 -0400

          From comp.compilers

Related articles
C regexp package that can save compiled expressions? johnl@iecc.com (John R Levine) (2004-08-13)
Re: C regexp package that can save compiled expressions? gneuner2@comcast.net (George Neuner) (2004-08-15)
Re: C regexp package that can save compiled expressions? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2004-08-15)
Re: C regexp package that can save compiled expressions? cbarron413@adelphia.net (Carl Barron) (2004-08-15)
Re: C regexp package that can save compiled expressions? cdc@maxnet.co.nz (Carl Cerecke) (2004-08-15)
| List of all articles for this month |

From: "John R Levine" <johnl@iecc.com>
Newsgroups: comp.compilers
Date: 13 Aug 2004 17:35:41 -0400
Organization: Compilers Central
Keywords: lex, question

Does anyone know of a regular expression package that lets you save
the compiled expression in a file and load it into an application
later?


A fairly effective anti-spam technique is to look at the reverse DNS
of incoming connections and to reject connections that come from known
blocks of dialup and otherwise poorly secured computers. You can
generally write a regular expression for the rDNS of each pool, but
there's a lot of pools, thousands of them, so on each incoming
connection the rDNS needs to be matched against thousands of regular
expressions.


Since you don't care which pattern matches, only whether it matches or
not, an obvious optimization would be to combine all of the patterns into
one big honking RE "pattern1 | pattern2 | ... | pattern N" and match the
rDNS against that, since the RE match time is proportional to the length
of the target string, not the complexity of the expression. The compile
time would be long, but the list of patterns changes rarely so one
compiled copy of the pattern would be used many times.


I could do this in flex, but that's not really the right tool since the
set of patterns does change now and then, and I don't need flex's ability
to run different code for each pattern.


So are there C regexp routines with a separate compiler? There used to be
one shipped with some versions of Unix, but I can't find it any more. The
standard regexp libraries are based on Henry Spencer's which compiles but
not into code you can dump out and reload.


Regards,
John Levine, johnl@iecc.com, Primary Perpetrator of "The Internet for Dummies",
Information Superhighwayman wanna-be, http://iecc.com/johnl, Mayor
"I dropped the toothpaste", said Tom, crestfallenly.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.