On May 29, 11:24 am, Duncan Booth <duncan.bo...@invalid.invalid> wrote: > andrew cooke <and...@acooke.org> wrote: > > Please can someone explain why the following fails: > > > from re import compile > > > p = compile(r'\bword\b') > > m = p.match(' word ') > > assert m [...] > You misunderstand what \b does: it doesn't match a space, it matches a 0 > length string on a boundary between a non-word and a word. [...]
That's what I thought it did... Then I read the docs and confused "empty string" with "space"(!) and convinced myself otherwise. I think I am going senile. Thanks very much! Andrew -- http://mail.python.org/mailman/listinfo/python-list