[docs] [issue12162] Documentation about re \number
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
nosy: Seth.Troisi, docs at python
title: Documentation about re \number
Python tracker <report at bugs.python.org>
More information about the docs