[Python-checkins] Fix the "Finding all Adverbs" example (GH-21420) (#28840)

Mariatta webhook-mailer at python.org
Sun Oct 10 17:44:07 EDT 2021


https://github.com/python/cpython/commit/5f44bb28fd9e98d681adff7e3329d6a863d3d5cd
commit: 5f44bb28fd9e98d681adff7e3329d6a863d3d5cd
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Mariatta <Mariatta at users.noreply.github.com>
date: 2021-10-10T14:43:58-07:00
summary:

Fix the "Finding all Adverbs" example (GH-21420) (#28840)

Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>
(cherry picked from commit dbd62e74dadda7868f1c0d497414c8f7e4c0b12b)

Co-authored-by: Rim Chatti <chattiriim at gmail.com>

files:
M Doc/library/re.rst

diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index ff7687cc936ec..b12ce4b9744f9 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -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



More information about the Python-checkins mailing list