Python RegEx through the ages, Appendix C: Summary table
Colliding names used by multiple non-interchangable modules (regex
and pcre
) are preceded by a disambiguating numerical superscript.
Included with | Base API | Engine | Main module name | C module name | Other modules | Notes |
---|---|---|---|---|---|---|
0.9.0–0.9.1 | First (exec ) | Henry Spencer | regexp | regexp | Posix Extended format. First public release of Python. Very simple API. | |
0.9.2–0.9.4 | First (match ) | Henry Spencer | regexp | regexp | exec method renamed to match . | |
0.9.5 | Second | GNU | (1st)regex | (1st)regex | regex_syntax | Emacs-style format by default, but changeable with flags. |
0.9.6–2.4 | Second | Ylönen based | (1st)regex | (1st)regex | regex_syntax , later also regsub | Changed to engine written by Tatu Ylönen. Emitting DeprecationWarning since 2.1, finally removed in 2.5.0alpha1. |
0.9.5–1.4 | First (match ) | (same as (1st)regex ) | regexp | (1st)regex | Wrapper around the contemporary (1st)regex module. Module removed in 1.5.0beta1. | |
1.5.0 | Third | Ylönen based (bytecode), custom (parsing) | re or re1 | reop | Perl-style format. New thread-safe API defined. Introduced as re in 1.5.0alpha3, implementation never fully debugged before it was superseded in 1.5.0alpha4. Retained as re1 for the 1.5.0 release, removed before 1.5.1. | |
1.5–2.3 | Third | PCRE (old) | re or pre | (1st)pcre | Introduced in 1.5.0alpha4 using what was then (late 1990s) a contemporary PCRE library. In particular, Unicode regular expressions were not yet supported. Renamed to pre in Python 2.† Removed in Python 2.4. | |
1.6†–present | Third | SecretLabs based | sre or re | _sre | sre_compile , sre_parse , sre_constants | Introduced with Python 2† as sre due to the need for a re implementation that supported Unicode regular expressions. Initially used a recursive matching scheme, this was changed in Python 2.4.0alpha1. Importing as sre deprecated in Python 2.5, only availabile as re in Python 3.x. |
PyPI python-pcre | mostly Third | PCRE | (2nd)pcre | _pcre | Extension binding by Arkadiusz Wahlig. Uses the third API except for substitution format string syntax, and can be configured to use the third-API syntax there too. Lacks the scanner APIs and DEBUG and LOCALE flags of the third API. Current PCRE does support Unicode regular expressions; note the name collision. | |
Planned for future inclusion; PyPI regex | Third with extensions | SecretLabs based | (2nd)regex | _regex | _regex_core | Extension by Matthew Barnett, forked from re (sre ). Prominent enough to get a mention in the documentation and “in principle approval for eventual stdlib inclusion”. Note the name collision with the second API. Backward-incompatibile behaviour fixes behind a version switch selectable in regex syntax and in API. |
† Python 1.6 is basically the state of Python 2 at the point that Guido left CNRI, released under contractual obligation or something similar: it incorporates many but not all distinctively 2.x features, it is accordingly not a true Python 1.x release; hence, “What’s new in Python 2.0” compares it with Python 1.5.2.