https://github.com/python/cpython/commit/c1744902c7c8cf7d68949db19a6e3e49dee4296c
commit: c1744902c7c8cf7d68949db19a6e3e49dee4296c
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2025-04-10T13:48:57Z
summary:

[3.13] gh-106482: Clarify documentation of character set in RE (GH-106517) 
(#132365)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Martin Panter <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>

files:
M Doc/library/re.rst

diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index 9db6f1da3be4db..a4ec538ee813a6 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -250,14 +250,23 @@ The special characters are:
      ``[a\-z]``) or if it's placed as the first or last character
      (e.g. ``[-a]`` or ``[a-]``), it will match a literal ``'-'``.
 
-   * Special characters lose their special meaning inside sets.  For example,
+   * Special characters except backslash lose their special meaning inside 
sets.
+     For example,
      ``[(+*)]`` will match any of the literal characters ``'('``, ``'+'``,
      ``'*'``, or ``')'``.
 
    .. index:: single: \ (backslash); in regular expressions
 
-   * Character classes such as ``\w`` or ``\S`` (defined below) are also 
accepted
-     inside a set, although the characters they match depend on the flags_ 
used.
+   * Backslash either escapes characters which have special meaning in a set
+     such as ``'-'``, ``']'``, ``'^'`` and ``'\\'`` itself or signals
+     a special sequence which represents a single character such as
+     ``\xa0`` or ``\n`` or a character class such as ``\w`` or ``\S``
+     (defined below).
+     Note that ``\b`` represents a single "backspace" character,
+     not a word boundary as outside a set, and numeric escapes
+     such as ``\1`` are always octal escapes, not group references.
+     Special sequences which do not match a single character such as ``\A``
+     and ``\Z`` are not allowed.
 
    .. index:: single: ^ (caret); in regular expressions
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to