match point

Chris Angelico rosuav at gmail.com
Tue Dec 22 06:07:43 EST 2015


On Tue, Dec 22, 2015 at 9:56 PM, Thierry <no at mail.com> wrote:
> Maybe re.match has an implementation that makes it more efficient? But
> then why would I ever use r'\A', since that anchor makes a pattern match
> in only a single position, and is therefore useless in functions like
> re.findall, re.finditer or re.split?

Much of the value of regular expressions is that they are NOT string
literals (just strings). Effectively, someone who has no authority to
change the code of the program can cause it to change from re.search
to re.match, simply by putting \A at the beginning of the search
string.

ChrisA



More information about the Python-list mailing list