summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-02-29 09:49:45 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-02-29 09:49:45 (GMT)
commit0b8123d8ae14520aa5c8623e1c829e9e44bfe04b (patch)
tree0a5fce405cb7bc5155ec30c53bfd7f0a55057008 /Doc
parent7b5649cd48fbccceb182ff5cde8eecc20a93954a (diff)
parent5a045b9f5493b12bc8421b55ffff10b6572bc22c (diff)
downloadcpython-0b8123d8ae14520aa5c8623e1c829e9e44bfe04b.zip
cpython-0b8123d8ae14520aa5c8623e1c829e9e44bfe04b.tar.gz
cpython-0b8123d8ae14520aa5c8623e1c829e9e44bfe04b.tar.bz2
#10713: merge with 3.2.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/re.rst22
1 files changed, 14 insertions, 8 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index d3d97c0..8df8aaa 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -330,16 +330,22 @@ the second character. For example, ``\$`` matches the character ``'$'``.
Matches the empty string, but only at the beginning or end of a word.
A word is defined as a sequence of Unicode alphanumeric or underscore
characters, so the end of a word is indicated by whitespace or a
- non-alphanumeric, non-underscore Unicode character. Note that
- formally, ``\b`` is defined as the boundary between a ``\w`` and a
- ``\W`` character (or vice versa). By default Unicode alphanumerics
- are the ones used, but this can be changed by using the :const:`ASCII`
- flag. Inside a character range, ``\b`` represents the backspace
- character, for compatibility with Python's string literals.
+ non-alphanumeric, non-underscore Unicode character. Note that formally,
+ ``\b`` is defined as the boundary between a ``\w`` and a ``\W`` character
+ (or vice versa), or between ``\w`` and the beginning/end of the string.
+ This means that ``r'\bfoo\b'`` matches ``'foo'``, ``'foo.'``, ``'(foo)'``,
+ ``'bar foo baz'`` but not ``'foobar'`` or ``'foo3'``.
+
+ By default Unicode alphanumerics are the ones used, but this can be changed
+ by using the :const:`ASCII` flag. Inside a character range, ``\b``
+ represents the backspace character, for compatibility with Python's string
+ literals.
``\B``
- Matches the empty string, but only when it is *not* at the beginning or end of a
- word. This is just the opposite of ``\b``, so word characters are
+ Matches the empty string, but only when it is *not* at the beginning or end
+ of a word. This means that ``r'py\B'`` matches ``'python'``, ``'py3'``,
+ ``'py2'``, but not ``'py'``, ``'py.'``, or ``'py!'``.
+ ``\B`` is just the opposite of ``\b``, so word characters are
Unicode alphanumerics or the underscore, although this can be changed
by using the :const:`ASCII` flag.