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

ken@basistech.com ken@basistech.com
Thu, 9 Mar 2000 11:48:15 -0500 (EST)


Perhaps there is a bug in the docs, too, since the use of \ in an expression
without using r works:

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( "\s*char\s*", "  char " )
<re.MatchObject instance at 7fdaf0>

-Ken

-----Original Message-----
From: Fred L. Drake, Jr. [mailto:fdrake@acm.org]
Sent: Thursday, March 09, 2000 11:45 AM
To: guido@python.org; ken@basistech.com
Cc: python-bugs-list@python.org; bugs-py@python.org
Subject: Re: [Python-bugs-list] Module re bug. \b fails (PR#230)



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

guido@python.org writes:
 > This is because \b is interpreted as a string literal
 > escape for backspace, before the regular expression parser gets to see

  I thought about that, but it *still* doesn't work:

>>> import re
>>> print re.match("\bchar\b", "  char ")
None
>>> print re.match(r"\bchar\b", "  char ")
None

  So not only is there a bug in the bug report, but somewhere in pcre
(or the Python binding) as well.


  -Fred

--
Fred L. Drake, Jr.	  <fdrake at acm.org>
Corporation for National Research Initiatives