FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.13] gh-106482: Clarify documentation of character set in RE (GH-106517) by miss-islington · Pull Request #132365 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 12 additions & 3 deletions Doc/library/re.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

Back | FazBrowse Home | New Git URL