[issue12162] Documentation about re \number

Seth Troisi report at bugs.python.org
Tue May 24 02:07:37 CEST 2011


New submission from Seth Troisi <braintwo at gmail.com>:

It would be nice to clarify re documentation on how to use \number.

current documentation lists three half examples:
"(.+) \1 matches 'the the' or '55 55', but not 'the end' (note the space after the group)."

This is rather confusing (at least to me) as it might be assumed that
re.search("(.+) \1", "the the") would return a match, which it does not.

A better example would be re.search("(\w+) \\1", "the the") which does match.

the other confusing portion is the requirement of the second "\" to make it match.

I would think that a quick example below the text would help.

>>> re.search("(\w+) \\1", "can you do the can can?") # \\1 matches the second can at the end of the sentence
<_sre.SRE_Match object at ...>

This is my first python issue and if I have misfiled or left out some information please tell me how to proceed.

----------
assignee: docs at python
components: Documentation
messages: 136708
nosy: Seth.Troisi, docs at python
priority: normal
severity: normal
status: open
title: Documentation about re \number
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12162>
_______________________________________


More information about the Python-bugs-list mailing list