Regular expression as dictionary key?

Daniel Yoo dyoo at
Mon Dec 3 18:13:20 EST 2001

Luke <LLoeffler at> wrote:
:> I suspect though that you really just want a way to use a
:> regular expression as a key, and created this singular/plural
:> example as justification.

: Yes and no.  This is one of many possible applications.  The plural 
: search is a naive example, but for this application doesn't need to be 
: excat either since the results are fuzzy anyway.

I wonder if there's a way of precomputing the keys so that doing fuzzy
searching on them won't be so expensive.  The difflib module allows
fuzzy searching, but I can imagine that it might be expensive to use.

Perl does have a "study()" function that allows the system to speed up
any searches on the text later on, so perhaps a similar system could
be cooked up with Python's regular expressions?

More information about the Python-list mailing list