New submission from Mike Lissner:

I just ran into a funny corner case I imagine others are aware of. When you 
write "\b" in Python, it is a single character: "\x08". So if you try to write 
a regex like:

words = '\b(.*)\b'

That won't work. But using a raw string will:

words = r'\b(.*)\b'

As will escaping it in this horrible fashion:

words = '\\b(.*)\\b'

I believe this doesn't affect any of the other regex flags, so I wonder if it's 
worth adding something to the docs to warn about this. I just spent a bunch of 
time trying to figure out why it seemed like \b wasn't working. A little tip in 
the docs would have gone a LONG way.

----------
assignee: docs@python
components: Documentation
messages: 285751
nosy: Mike.Lissner, docs@python
priority: normal
severity: normal
status: open
title: \b requires raw strings or to be escaped. Update docs with that hint?
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29315>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to