[Python-Dev] Discordance in documentation... (original) (raw)
gminick gminick at hacker.pl
Thu Sep 4 23:04:48 EDT 2003
- Previous message: Solutions for LC_NUMERIC, was Re: [Python-Dev] Re: Be Honest about LC_NUMERIC [REPOST]
- Next message: [Python-Dev] Re: Discordance in documentation...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
...or is this just me?
Let's take a look, Reference Lib, 4.2.1 Regular Expression Syntax says:
"|" A|B, where A and B can be arbitrary REs, creates a regular expression that will match either A or B. [...] REs separated by "|" are tried from left to right, and the first one that allows the complete pattern to match is considered the accepted branch. This means that if A matches, B will never be tested, even if it would produce a longer overall match. [...]
And now a little test:
import re a = "Fuentes Rushdie Marquez" print re.search("Rushdie|Fuentes", a).group() # returns "Fuentes"
According to the documentation I suspected it will return "Rushdie" rather than "Fuentes", but it looks like it returns first part of the string that matches rather than first part of regular expression.
-- [ Wojtek Walczak - gminick (at) underground.org.pl ] [ <http://gminick.linuxsecurity.pl/> ] [ "...rozmaite zwroty, matowe od patyny dawnosci." ]
- Previous message: Solutions for LC_NUMERIC, was Re: [Python-Dev] Re: Be Honest about LC_NUMERIC [REPOST]
- Next message: [Python-Dev] Re: Discordance in documentation...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]