Skip to content

Commit e1b084c

Browse files
committed
Remove \b from double-word example
1 parent e370981 commit e1b084c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Doc/howto/regex.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,11 +902,11 @@ raw string when incorporating backreferences in a RE.)
902902

903903
For example, the following RE detects doubled words in a string. ::
904904

905-
>>> p = re.compile(r'\b(\w+)\b\s+\1\b')
905+
>>> p = re.compile(r'\b(\w+)\s+\1\b')
906906
>>> p.search('Paris in the the spring').group()
907907
'the the'
908908

909-
The first part of the pattern, ``\b(\w+)\b``, will match an entire word and
909+
The first part of the pattern, ``\b(\w+)``, will match an entire word and
910910
capture the word as group 1. The pattern then matches some whitespace with
911911
``\s+`` and checks for the word again with ``\1\b``. The second \b is
912912
necessary to ensure that the backreference is matching an entire word;

0 commit comments

Comments
 (0)