[issue20810] literal re fails to match

Jonathan Epstein report at bugs.python.org
Fri Feb 28 20:24:21 CET 2014


Jonathan Epstein added the comment:

Sorry, this was dumb.  Thanks for your patience.

On Fri, Feb 28, 2014 at 2:23 PM, Eric V. Smith <report at bugs.python.org>wrote:

>
> Eric V. Smith added the comment:
>
> re.match requires a match at the beginning of the string. From the docs:
> "If zero or more characters at the beginning of string match the regular
> expression pattern, ...".
>
> If you switch to re.search, they'll all match:
>
> >>> re.search('larvalolympiad',mainProjectsPath)
> <_sre.SRE_Match object at 0xffed54f0>
>
> >>> re.match('.*larvalolympiad.*',mainProjectsPath)
> <_sre.SRE_Match object at 0xffed5870>
>
> >>> re.search('/larvalolympiad/',mainProjectsPath)
> <_sre.SRE_Match object at 0xffed54f0>
>
> ----------
> nosy: +eric.smith
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue20810>
> _______________________________________
>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20810>
_______________________________________


More information about the Python-bugs-list mailing list