regex search with a space as the fist character

Diez B. Roggisch deets at nospam.web.de
Thu Sep 17 09:06:47 CEST 2009


Daniel Santos schrieb:
> Hello,
> 
>>>> print re.compile('u ').search(" u box2", 1)
> <_sre.SRE_Match object at 0x7ff1d918>
>>>> print re.compile(' u ').search(" u box2", 1)
> None
> 
> 
> Why ?

because you start searching at the offset 1, which means you try to find 
" u " in "u box2" - and that's not found.

Diez



More information about the Python-list mailing list