Re: C regexp package that can save compiled expressions?

Carl Cerecke <cdc@maxnet.co.nz>
15 Aug 2004 22:21:52 -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: Carl Cerecke <cdc@maxnet.co.nz>
Newsgroups: comp.compilers
Date: 15 Aug 2004 22:21:52 -0400
Organization: TelstraClear
References: 04-08-090
Keywords: lex
Posted-Date: 15 Aug 2004 22:21:52 EDT

John R Levine wrote:
> 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?


Python can serialize ('pickle') compiled regular expressions, and python
interfaces well with C.


e.g.


import re, pickle


r = re.compile("foo|bar|baz")
fid = open("regexp.file","w")
pickle.dump(r,fid)
fid.close()




fid2 = open("regexp.file","r")
reg = pickle.load(fid2)
fid2.close()


print reg.search("afooa").group()






Cheers,
Carl.


Post a followup to this message

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