re.match(...) fails to find a match

Mitch Chapman chapman at bioreason.com
Wed Jun 20 15:21:01 EDT 2001


Kevin Cole wrote:
> Just attempting to get an ampersand working, I've tried:
> 
>    p = re.compile('[&]+')
> [...]
>    print p.match('This string & that string')
> 
> always returns "None".

The docstring for p.match notes that it tries to match at the beginning
of
a string.  Try p.search instead.

-- 
Mitch Chapman
Mitch.Chapman at bioreason.com



More information about the Python-list mailing list