Why no match?
Robin Becker
robin at jessikat.fsnet.co.uk
Mon Dec 17 19:33:54 EST 2001
In article <8ctT7.13638$o9.556973 at news1.tin.it>, Alex Martelli
<aleax at aleax.it> writes
....
>
>Sure, this matches -- look at the end of the pattern: an equal sign, 0 or
>more spaces, one digit, zero or more spaces, no constraints on what comes
>after. This part I just described in words matches the '=1' part of the
>argument to method match, no?
>
>>>>> re.compile(r'^self\s*\.\s*test\s*=\s*\d\s*$').match('self.test=11')
>>>>>
>
>But this specifies that the string ends after the match, and it doesn't, as
>it has an extra digit '1' at the end. So, the result is None.
>
>Maybe you want \d+ (one *or more* digits) in the pattern rather than just
>\d (*exactly* one digit) as you have now?
too late too late
--
Robin Becker
More information about the Python-list
mailing list