8000 bpo-35584: Clarify role of caret in a class class (GH-11946) (GH-11947) · python/cpython@bb9ddee · GitHub
[go: up one dir, main page]

Skip to content

Commit bb9ddee

Browse files
bpo-35584: Clarify role of caret in a class class (GH-11946) (GH-11947)
https://bugs.python.org/issue35584 (cherry picked from commit 3bacf61) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
< 8000 /div>
1 parent e8bf04d commit bb9ddee

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Doc/howto/regex.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ special nature.
9696

9797
You can match the characters not listed within the class by :dfn:`complementing`
9898
the set. This is indicated by including a ``'^'`` as the first character of the
99-
class; ``'^'`` outside a character class will simply match the ``'^'``
100-
character. For example, ``[^5]`` will match any character except ``'5'``.
99+
class. For example, ``[^5]`` will match any character except ``'5'``. If the
100+
caret appears elsewhere in a character class, it does not have special meaning.
101+
For example: ``[5^]`` will match either a ``'5'`` or a ``'^'``.
101102

102103
Perhaps the most important metacharacter is the backslash, ``\``. As in Python
103104
string literals, the backslash can be followed by various characters to signal

0 commit comments

Comments
 (0)
0