Regular Expressions - Python vs Perl

Terry Reedy tjreedy at udel.edu
Thu Apr 21 18:41:06 EDT 2005


"codecraig" <codecraig at gmail.com> wrote in message 
news:1114092105.964664.211430 at l41g2000cwc.googlegroups.com...

>  I am interested in regular expressions and how Perl and Python
> compare.  Particulary, I am interested in performance (i.e. speed),
> memory usage, flexibility, completeness (i.e. supports simple and
> complex regex operations...basically is RegEx a strong module/library
> in Python?)

Depending upon you particular application, 'completeness' may be a more 
relevant concern than 'performance'.  I believe the original Python regex 
engine did not have all the Perl extensions, some of them decidedly 'non 
regular'.  It was replace by the 'perl-compatible regex engine' (pcre or 
pre), written in C by a non-pythonista so that other 
languages/applications, like Python, could drop it in and have what the 
title claimed -- perl-like re capability.  The current sre engine was 
locally written to include unicode, with the re syntax unchanged (? or 
nearly so) from the pre.  So I would say that the answer to your last 
question of 'yes'.

Terry J. Reedy






More information about the Python-list mailing list