Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.14] gh-122055: Clarify documentation for empty matches in RE (GH-133169)#134217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletionsDoc/library/re.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -991,8 +991,8 @@ Functions
That way, separator components are always found at the same relative
indices within the result list.

Emptymatchesfor the pattern split the string only when not adjacent
to a previousempty match.
Adjacent emptymatchesare not possible, but an empty match can occur
immediately after a non-empty match.

.. code:: pycon

Expand DownExpand Up@@ -1095,9 +1095,12 @@ Functions

The optional argument *count* is the maximum number of pattern occurrences to be
replaced; *count* must be a non-negative integer. If omitted or zero, all
occurrences will be replaced. Empty matches for the pattern are replaced only
when not adjacent to a previous empty match, so ``sub('x*', '-', 'abxd')`` returns
``'-a-b--d-'``.
occurrences will be replaced.

Adjacent empty matches are not possible, but an empty match can occur
immediately after a non-empty match.
As a result, ``sub('x*', '-', 'abxd')`` returns ``'-a-b--d-'``
instead of ``'-a-b-d-'``.

.. index:: single: \g; in regular expressions

Expand DownExpand Up@@ -1128,8 +1131,7 @@ Functions
.. versionchanged:: 3.7
Unknown escapes in *repl* consisting of ``'\'`` and an ASCII letter
now are errors.
Empty matches for the pattern are replaced when adjacent to a previous
non-empty match.
An empty match can occur immediately after a non-empty match.

.. versionchanged:: 3.12
Group *id* can only contain ASCII digits.
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp