[Python-checkins] bpo-35584: Clarify role of caret in a class class (GH-11946) (GH-11948)

Raymond Hettinger webhook-mailer at python.org
Tue Feb 19 15:26:14 EST 2019

commit: 6ee41793d2204c54bdf8f477ae61d016a7eca932
branch: 2.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Raymond Hettinger <rhettinger at users.noreply.github.com>
date: 2019-02-19T12:26:11-08:00

bpo-35584: Clarify role of caret in a class class (GH-11946) (GH-11948)

(cherry picked from commit 3bacf6126522a9b3bcb6be0c4f3ee6a895dfe772)

Co-authored-by: Raymond Hettinger <rhettinger at users.noreply.github.com>

M Doc/howto/regex.rst

diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst
index 082fc0129915..81c049501306 100644
--- a/Doc/howto/regex.rst
+++ b/Doc/howto/regex.rst
@@ -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

More information about the Python-checkins mailing list