Some time ago I discovered this difference between regular expressions
in Python and Perl:

Python

        \A matches at start of string
        \Z matches at end of string

Perl

        \A matches at start of string
        \Z matches before terminal newline or at end of string
        \z matches at end of string

In Perl \A == ^ and \Z == $ in single-string mode, but in Python \A == ^
and \Z != $ in single-string mode.

Obviously, changing Python's \Z to match Perl's could break existing
code. \z could be added, but with the opposite meaning to Perl's:

        Python's \Z == Perl's \z
        Python's \z == Perl's \Z

Would that be confusing?

Any suggests welcome.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to