[Python-bugs-list] Module re bug. \b fails (PR#230)

guido@python.org guido@python.org
Thu, 9 Mar 2000 11:26:19 -0500 (EST)


> \b doesn't seem to work as advertised in the following expression:
> re.match( "\bchar\b", "  char " )

This is because \b is interpreted as a string literal
escape for backspace, before the regular expression parser gets to see
it.

As the re module docs explain, you should always use r"\bchar\b" to
avoid this kind of problem.

--Guido van Rossum (home page: http://www.python.org/~guido/)