]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix the "Finding all Adverbs" example (GH-21420) (#28840)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 10 Oct 2021 21:43:58 +0000 (14:43 -0700)
committerGitHub <noreply@github.com>
Sun, 10 Oct 2021 21:43:58 +0000 (14:43 -0700)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit dbd62e74dadda7868f1c0d497414c8f7e4c0b12b)

Co-authored-by: Rim Chatti <chattiriim@gmail.com>
Doc/library/re.rst

index ff7687cc936ec9ef4c276ca38e62283c0e070b43..b12ce4b9744f944b4347bc74c03f6243c19a222f 100644 (file)
@@ -1572,7 +1572,7 @@ find all of the adverbs in some text, they might use :func:`findall` in
 the following manner::
 
    >>> text = "He was carefully disguised but captured quickly by police."
-   >>> re.findall(r"\w+ly", text)
+   >>> re.findall(r"\w+ly\b", text)
    ['carefully', 'quickly']
 
 
@@ -1586,7 +1586,7 @@ a writer wanted to find all of the adverbs *and their positions* in
 some text, they would use :func:`finditer` in the following manner::
 
    >>> text = "He was carefully disguised but captured quickly by police."
-   >>> for m in re.finditer(r"\w+ly", text):
+   >>> for m in re.finditer(r"\w+ly\b", text):
    ...     print('%02d-%02d: %s' % (m.start(), m.end(), m.group(0)))
    07-16: carefully
    40-47: quickly