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

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


> I still believe it is broken.  See these examples:
> 
> ----------------------------------------
> 1) My attempt at your suggestion (FAILS)
> ----------------------------------------
> C:\Projects\Unicode Tutorial\Scripts>python
> Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import re
> >>> print re.match( r"\bchar\b", "  char " )
> None
> >>>
> 
> ----------------------------------------
> 2) My use of \ without using r (WORKS)
> ---------------------------------------->>> print re.match( "\s*char\s*", "
> char " )
> <re.MatchObject instance at 7fe260>
> 
> Forgive the missteps of a python newbie.  I did check the docs and have
> tried your suggestion.  Am I misinterpreting something concerning proper
> syntax?
> 
> It still doesn't work.

Hm, you're right.  Note that \s is not a recognized string escape, so
r"\s" == "\s"; however r"\b" != "\b".

I can't explain why r"x\b" doesn't match "x " though.

I'll ask Andrew.

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