re.match and non-alphanumeric characters
Steve Holden
steve at holdenweb.com
Sun Nov 16 18:54:12 EST 2008
Diez B. Roggisch wrote:
> John Machin schrieb:
>> On Nov 17, 4:44 am, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
>>
>>> Match matches the whole string.
>>
>> *ONLY* if the pattern ends with "$" or r"\Z"
>
>
> You think so?
>
> import re
>
> rex = re.compile("abc.*def")
>
> if rex.match("abc0123455678def"):
> print "matched"
>
Your test is inconclusive: necessary, but not sufficient.
>>> rex = re.compile("abc.*def")
>>>
>>> if rex.match("abc0123455678defPLUSEXTRASTUFF"):
... print "Matched"
...
Matched
>>>
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list