On re / regex replacement

Vlastimil Brom vlastimil.brom at gmail.com
Sun Aug 28 09:40:05 EDT 2011


2011/8/28 jmfauth <wxjmfauth at gmail.com>:
> There is actually a discussion on the dev-list about the replacement
> of "re" by "regex".
>...
> If I can undestand the ASCII flag, ASCII being the "lingua franca" of
> almost all codings, I am more skeptical about the LOCALE/UNICODE
> flags.
>
> There is in my mind some kind of conflict here. What is 100% unicode
> compliant shoud be locale independent ("Unicode.org") and a locale
> depedency means a loss of unicode compliance.
>
> I'm fearing some potential problems here:  Users or modules working
> in one mode, while some others are working in the other mode.
>
>...
> jmf
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


As I understand it, regex was designed to be as much compatible with
re as possible, sometimes even some problematic (in some
interpretation) behaviour is retained as default and "corrected" via
the NEW flag (e.g. zero-width split). Also the LOCALE flag seems to be
considered as legacy feature and kept with the same behaviour like re;
cf.: http://code.google.com/p/mrab-regex-hg/issues/detail?id=6&can=1
In my opinon, the LOCALE flag is not reliable (in a way I would
imagine) in either re or regex.

In the area of flags regex should work the same way like re or it just
adds more possibilities (REVERSE for backwards search,  ASCII as the
complement for unicode, NEW to enable some incompatible additions or
corrections, where the original behaviour could be relied on).

The only (understandable) incompatibility I encounter in regex are the
new features requiring special syntax, which would obviously raise
errors in re or which would be matched literally instead.
see
http://code.google.com/p/mrab-regex-hg/wiki/GeneralDetails#Additional_features
for an overview of the additions.

Personally I am very happy with regex, both with its features as well
as with the support and maintenance by its developer;
however I am mostly using it for manually entered patterns, and less
for hardcoded operation.

regards,
   Vlastimil Brom



More information about the Python-list mailing list