[Baypiggies] Bug in re module?
aleax at google.com
Thu Nov 29 20:11:56 CET 2012
'match' requires starting from the start of the string. `line` starts with
a tab which is not in the pattern. I think you want re.search (which does
not imply anchor at the beginning the way re.match does).
On Thu, Nov 29, 2012 at 10:57 AM, Mitch Patenaude <patenaude at gmail.com>wrote:
> Maybe I'm misunderstanding, but I think I have a bug in the re module:
> mpatenaude-mbp:tmp mpatenaude$ python2.7
> Python 2.7.3 (default, Apr 13 2012, 00:05:08)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import re
> >>> line="\tTest2.1\n"
> >>> matchobj = re.match('Test2.1',line,0)
> >>> matchobj
> It's not matching a very simple string.
> (I know that '.' is a special character, but it should match any
> character, including a period itself, so I didn't bother to escape it.)
> It *works* if I use findall rather than match, but I don't understand why.
> -- Mitch
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Baypiggies