<div dir="ltr"><a href="http://docs.python.org/3.3/library/re.html">http://docs.python.org/3.3/library/re.html</a><br><div><br></div><div>6.2.1. Regular Expression Syntax<br></div><div><br></div><div>(way down)</div><div><br>
</div><div>it says:</div><div><br></div><div><div>\number</div><div>Matches the contents of the group of the same number. Groups are numbered starting from 1. For example, (.+) \1 matches 'the the' or '55 55', but not 'the end' (note the space after the group). This special sequence can only be used to match one of the first 99 groups. If the first digit of number is 0, or number is 3 octal digits long, it will not be interpreted as a group match, but as the character with octal value number. Inside the '[' and ']' of a character class, all numeric escapes are treated as characters.</div>
</div><div><br></div><div>The example of what does not work is wrong</div><div><br></div><div>In [1]: import re<br></div><div><br></div><div><div>In [2]: re.findall(r'(.+) \1','the end')</div><div>Out[2]: ['e']</div>
</div><div><br></div><div>It probably should beĀ </div><div><br></div><div><div>\number</div><div>Matches the contents of the group of the same number. Groups are numbered starting from 1. For example, (.+) \1 matches 'the the' or '55 55', but not 'thethe' (note the space after the group). This special sequence can only be used to match one of the first 99 groups. If the first digit of number is 0, or number is 3 octal digits long, it will not be interpreted as a group match, but as the character with octal value number. Inside the '[' and ']' of a character class, all numeric escapes are treated as characters.</div>
</div><div><br></div><div>-Alexander</div></div>