[docs] bug in re documentation (python 3.3.2)

Georg Brandl georg at python.org
Sun Oct 6 12:58:52 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 27.06.2013 02:25, schrieb Alexander Heger:
> http://docs.python.org/3.3/library/re.html
> 
> 6.2.1. Regular Expression Syntax
> 
> (way down)
> 
> it says:
> 
> \number 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.
> 
> The example of what does not work is wrong
> 
> In [1]: import re
> 
> In [2]: re.findall(r'(.+) \1','the end') Out[2]: ['e']
> 
> It probably should be
> 
> \number 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.

Hi Alexander,

thanks for the report; this is now fixed and should be online soon.

cheers,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (GNU/Linux)

iEYEARECAAYFAlJRQmwACgkQN9GcIYhpnLALdgCdG16SAUH9eBZWjXNnl6yWGkeW
0bcAnRXELerjnSVWaAO2yx4F/iWZPqLR
=c8Xy
-----END PGP SIGNATURE-----


More information about the docs mailing list