mirror of
https://github.com/python/cpython.git
synced 2025-11-11 22:55:08 +00:00
Fix the "Finding all Adverbs" example (GH-21420)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
543acbce5a
commit
dbd62e74da
1 changed files with 2 additions and 2 deletions
|
|
@ -1572,7 +1572,7 @@ find all of the adverbs in some text, they might use :func:`findall` in
|
||||||
the following manner::
|
the following manner::
|
||||||
|
|
||||||
>>> text = "He was carefully disguised but captured quickly by police."
|
>>> 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']
|
['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::
|
some text, they would use :func:`finditer` in the following manner::
|
||||||
|
|
||||||
>>> text = "He was carefully disguised but captured quickly by police."
|
>>> 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)))
|
... print('%02d-%02d: %s' % (m.start(), m.end(), m.group(0)))
|
||||||
07-16: carefully
|
07-16: carefully
|
||||||
40-47: quickly
|
40-47: quickly
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue