]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35584: Clarify role of caret in a class class (GH-11946) (GH-11948)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 19 Feb 2019 20:26:11 +0000 (12:26 -0800)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>
Tue, 19 Feb 2019 20:26:11 +0000 (12:26 -0800)
https://bugs.python.org/issue35584
(cherry picked from commit 3bacf6126522a9b3bcb6be0c4f3ee6a895dfe772)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Doc/howto/regex.rst

index 082fc012991525ca3ec7da994b1a69382d7f35d7..81c0495013068116537b79b03ff521a6e28b0237 100644 (file)
@@ -101,8 +101,9 @@ special nature.
 
 You can match the characters not listed within the class by :dfn:`complementing`
 the set.  This is indicated by including a ``'^'`` as the first character of the
-class; ``'^'`` outside a character class will simply match the ``'^'``
-character.  For example, ``[^5]`` will match any character except ``'5'``.
+class. For example, ``[^5]`` will match any character except ``'5'``.  If the
+caret appears elsewhere in a character class, it does not have special meaning.
+For example: ``[5^]`` will match either a ``'5'`` or a ``'^'``.
 
 Perhaps the most important metacharacter is the backslash, ``\``.   As in Python
 string literals, the backslash can be followed by various characters to signal