[issue20810] literal re fails to match

2014-02-28 Thread Jonathan Epstein

New submission from Jonathan Epstein:

All 3 of these regex's should match, but in practice only m2 does.  Found deep 
in the bowels of debugging a larger problem.


import re

mainProjectsPath = '/groups/larvalolympiad/larvalolympiad/Projects/'

m1 = re.match('larvalolympiad',mainProjectsPath)
m2 = re.match('.*larvalolympiad.*',mainProjectsPath)
m3 = re.match('/larvalolympiad/',mainProjectsPath)

print(m1)
print(m2)
print(m3)

--
components: Regular Expressions
messages: 212463
nosy: Jonathan.Epstein, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: literal re fails to match
type: behavior
versions: Python 2.7, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20810
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20810] literal re fails to match

2014-02-28 Thread Jonathan Epstein

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 rep...@bugs.python.orgwrote:


 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 rep...@bugs.python.org
 http://bugs.python.org/issue20810
 ___


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20810
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com