Vlad Ioan Topan

My playground

Archive for February 2009

Python snippets (1)

leave a comment »

Apparently, Python 2.6 supports a max. of 100 named groups in regular expressions. It also doesn’t support constructs such as (?i:…), which makes it impossible to selectively mark groups as case insensitive in a regex with more than 100 groups. The performance penalty for making the complete regex case insensitive is enormous (roughly double running time), so the only solution to my problem (which involves searching for a large number of patterns, some of them case insensitive) appears to be linking to an external regex module, such as PCRE (which will require bindings for Python, as PCRE for example doesn’t have any (not any more, at least)), or implementing my own pattern searching library. This should be fun.


Written by vtopan

February 18, 2009 at 8:29 PM