Why no match?

Robin Becker robin at jessikat.fsnet.co.uk
Mon Dec 17 13:00:05 CET 2001

In article <hZu5xLATzdH8EwE6 at jessikat.demon.co.uk>, Robin Becker
<robin at jessikat.fsnet.co.uk> writes
>I'm puzzled as to why the second of these pattern matches fails. They
>only differ in that the second is supposed to match to the end of line.
>Can any regexpert supply an answer?
>>>> import re
>>>> re.compile(r'^self\s*\.\s*test\s*=\s*\d\s*').match('self.test=11')
><SRE_Match object at 010711F8>
>>>> re.compile(r'^self\s*\.\s*test\s*=\s*\d\s*$').match('self.test=11')
my own stupidity the patter should be

ie to allow one or more digits grrrh :(
Robin Becker

More information about the Python-list mailing list