summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-02-19 19:32:18 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-02-19 19:32:18 (GMT)
commit3bacf6126522a9b3bcb6be0c4f3ee6a895dfe772 (patch)
treedd4811c986f729a0cdcf0dc19f9021142d05f331
parent3ef6344ee53f59ee86831ec36ed2c6f93a56229d (diff)
downloadcpython-3bacf6126522a9b3bcb6be0c4f3ee6a895dfe772.zip
cpython-3bacf6126522a9b3bcb6be0c4f3ee6a895dfe772.tar.gz
cpython-3bacf6126522a9b3bcb6be0c4f3ee6a895dfe772.tar.bz2
bpo-35584: Clarify role of caret in a class class (GH-11946)
https://bugs.python.org/issue35584
-rw-r--r--Doc/howto/regex.rst5
1 files changed, 3 insertions, 2 deletions
diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst
index b09f748..d385d99 100644
--- a/Doc/howto/regex.rst
+++ b/Doc/howto/regex.rst
@@ -96,8 +96,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