This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Cristian Barbarosie
Recipients Cristian Barbarosie, docs@python
Date 2017-04-06.04:40:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In the Regular Expression HOWTO
the last example in the "Grouping" section has a bug. The code is supposed to find repeated words, but it catches false repetitions.

>>> p = re.compile(r'(\b\w+)\s+\1')
>>>'Paris in the the spring').group()
'the the'
>>>'k is the thermal coefficient').group()
'the the'

I propose adding a \b after \1, this solves the problem :

>>> p = re.compile(r'(\b\w+)\s+\1\b')
>>>'Paris in the the spring').group()
'the the'
>>> print'k is the thermal coefficient')
Date User Action Args
2017-04-06 04:40:42Cristian Barbarosiesetrecipients: + Cristian Barbarosie, docs@python
2017-04-06 04:40:42Cristian Barbarosiesetmessageid: <>
2017-04-06 04:40:42Cristian Barbarosielinkissue30004 messages
2017-04-06 04:40:42Cristian Barbarosiecreate