summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-01-04 09:08:24 (GMT)
committerGitHub <noreply@github.com>2018-01-04 09:08:24 (GMT)
commit1e6d8525f9dd3dcdc83adb93b164082c8b95d17a (patch)
tree5bca0de34a7524b4a3208056b2cefdc32ee3fcbd /Doc
parentf24c1857a8a1ba3efb3f957d43371bc9499e3c86 (diff)
downloadcpython-1e6d8525f9dd3dcdc83adb93b164082c8b95d17a.zip
cpython-1e6d8525f9dd3dcdc83adb93b164082c8b95d17a.tar.gz
cpython-1e6d8525f9dd3dcdc83adb93b164082c8b95d17a.tar.bz2
bpo-32211: Document the existing bug in re.findall() and re.finditer(). (#4695)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/re.rst14
1 files changed, 10 insertions, 4 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index fae8945..874c8dd 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -719,14 +719,21 @@ form.
Splitting on a pattern that could match an empty string now raises
a warning. Patterns that can only match empty strings are now rejected.
+
.. function:: findall(pattern, string, flags=0)
Return all non-overlapping matches of *pattern* in *string*, as a list of
strings. The *string* is scanned left-to-right, and matches are returned in
the order found. If one or more groups are present in the pattern, return a
list of groups; this will be a list of tuples if the pattern has more than
- one group. Empty matches are included in the result unless they touch the
- beginning of another match.
+ one group. Empty matches are included in the result.
+
+ .. note::
+
+ Due to the limitation of the current implementation the character
+ following an empty match is not included in a next match, so
+ ``findall(r'^|\w+', 'two words')`` returns ``['', 'wo', 'words']``
+ (note missed "t"). This is changed in Python 3.7.
.. function:: finditer(pattern, string, flags=0)
@@ -734,8 +741,7 @@ form.
Return an :term:`iterator` yielding :ref:`match objects <match-objects>` over
all non-overlapping matches for the RE *pattern* in *string*. The *string*
is scanned left-to-right, and matches are returned in the order found. Empty
- matches are included in the result unless they touch the beginning of another
- match.
+ matches are included in the result. See also the note about :func:`findall`.
.. function:: sub(pattern, repl, string, count=0, flags=0)