Re: RE Engine error with sub()

2005-04-16 Thread Maurice LING
Hi all, I think I might have a workaround to this problem but have no idea how to work it through. I hope that someone can kindly help me out because I do not quite understand the mechanics of the _make_regex() method in the original codes... My idea is, instead of having one UserDict, have a

Re: RE Engine error with sub()

2005-04-16 Thread Maurice LING
Solved it. Instead of modifying Replacer class, I've made another class which initiates a list of Replacer objects from a list of substitution rule files. And then iterates through the list of Replacer objects and calls upon their own substitute() method. It seems to work. Thanks for all your

Re: RE Engine error with sub()

2005-04-15 Thread André Søreng
Instead of using regular expressions, you could perhaps use a multiple keyword matcher, and then for each match, replace it with the correct string. http://hkn.eecs.berkeley.edu/~dyoo/python/ahocorasick/ contains the Aho-Corasick algorithm written in C with a Python extension. Maurice LING wrote:

Re: RE Engine error with sub()

2005-04-15 Thread Dennis Benzinger
Maurice LING schrieb: Hi, I have the following codes: from __future__ import nested_scopes [...] Are you still using Python 2.1? In every later version you don't need the from __future__ import nested_scopes line. So, if you are using Python 2.1 I strongly recommend upgrading to Python 2.4.1.

Re: RE Engine error with sub()

2005-04-15 Thread André Søreng
The Internal error in regular expression engine occurs also in Python 2.4.0 when creating a regular expression containing more than or's (|). Dennis Benzinger wrote: Maurice LING schrieb: Hi, I have the following codes: from __future__ import nested_scopes [...] Are you still using Python

Re: RE Engine error with sub()

2005-04-15 Thread Maurice LING
Hi Dennis, Dennis Benzinger wrote: Maurice LING schrieb: Hi, I have the following codes: from __future__ import nested_scopes [...] Are you still using Python 2.1? In every later version you don't need the from __future__ import nested_scopes line. So, if you are using Python 2.1 I strongly

RE Engine error with sub()

2005-04-14 Thread Maurice LING
Hi, I have the following codes: from __future__ import nested_scopes import re from UserDict import UserDict class Replacer(UserDict): An all-in-one multiple string substitution class. This class was contributed by Xavier Defrang to the ASPN Python Cookbook