summaryrefslogtreecommitdiff
path: root/Doc/library/re.rst
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2018-08-22 15:55:41 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2018-08-22 15:55:51 +0900
commit48da3963020bb71b5952d410358e9edc324c4562 (patch)
tree77d9ce3b065bfc7b07f882f5e1285c4e884ef8ba /Doc/library/re.rst
parent7628643e8630407914001b95e687a33e0a5715bb (diff)
downloadpython-48da3963020bb71b5952d410358e9edc324c4562.tar.gz
python-48da3963020bb71b5952d410358e9edc324c4562.tar.bz2
python-48da3963020bb71b5952d410358e9edc324c4562.zip
Imported Upstream version 2.7.15upstream/2.7.15
Change-Id: Id9c63619cb3e0b8e0af22357474f6f6429c63c61 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'Doc/library/re.rst')
-rw-r--r--Doc/library/re.rst17
1 files changed, 12 insertions, 5 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index d0798b7..c424230 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -532,7 +532,8 @@ form.
This flag allows you to write regular expressions that look nicer and are
more readable by allowing you to visually separate logical sections of the
pattern and add comments. Whitespace within the pattern is ignored, except
- when in a character class or when preceded by an unescaped backslash.
+ when in a character class, or when preceded by an unescaped backslash,
+ or within tokens like ``*?``, ``(?:`` or ``(?P<...>``.
When a line contains a ``#`` that is not in a character class and is not
preceded by an unescaped backslash, all characters from the leftmost such
``#`` through the end of the line are ignored.
@@ -610,14 +611,21 @@ form.
Added the optional flags argument.
+
.. 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.
.. versionadded:: 1.5.2
@@ -630,8 +638,7 @@ form.
Return an :term:`iterator` yielding :class:`MatchObject` instances 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`.
.. versionadded:: 2.2