File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -844,7 +844,7 @@ backreferences in a RE.
844
844
845
845
For example, the following RE detects doubled words in a string. ::
846
846
847
- >>> p = re.compile(r'(\b \w+)\s+\1')
847
+ >>> p = re.compile(r'\b( \w+)\s+\1\b ')
848
848
>>> p.search('Paris in the the spring').group()
849
849
'the the'
850
850
@@ -943,9 +943,9 @@ number of the group. There's naturally a variant that uses the group name
943
943
instead of the number. This is another Python extension: ``(?P=name) `` indicates
944
944
that the contents of the group called *name * should again be matched at the
945
945
current point. The regular expression for finding doubled words,
946
- ``(\b \w+)\s+\1 `` can also be written as ``(?P<word>\b\ w+)\s+(?P=word) ``::
946
+ ``\b( \w+)\s+\1\b `` can also be written as ``\b (?P<word>\w+)\s+(?P=word)\b ``::
947
947
948
- >>> p = re.compile(r'(?P<word>\b\ w+)\s+(?P=word)')
948
+ >>> p = re.compile(r'\b (?P<word>\w+)\s+(?P=word)\b ')
949
949
>>> p.search('Paris in the the spring').group()
950
950
'the the'
951
951
You can’t perform that action at this time.
0 commit comments