New submission from Cristian Barbarosie: In the Regular Expression HOWTO https://docs.python.org/3.6/howto/regex.html#regex-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') >>> p.search('Paris in the the spring').group() 'the the' >>> p.search('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') >>> p.search('Paris in the the spring').group() 'the the' >>> print p.search('k is the thermal coefficient') None ---------- assignee: docs@python components: Documentation messages: 291209 nosy: Cristian Barbarosie, docs@python priority: normal severity: normal status: open title: in regex-howto, improve example on grouping type: enhancement versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30004> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com