xolox / vim-easytags

Automated tag file generation and syntax highlighting of tags in Vim
http://peterodding.com/code/vim/easytags/
1.01k stars 109 forks source link

Replace \0 by \g<0> in python sub #78

Closed mat-tso closed 10 years ago

mat-tso commented 10 years ago

The back reference \g<0> substitutes in the entire substring matched by the RE. http://docs.python.org/2/library/re.html#re.sub

The documentation does not mention\0 as an alias to it (although \1 to \9 works). I guess this alias (\0 <=> \g<0>) existed in old python versions but it is not the case any more.

In python 2.7 and 3.3:

> import re; re.compile(r'123').sub(r'@\0@',"ab123cd")
'ab@\x00@cd' # KO
> import re; re.compile(r'123').sub(r'@\g<0>@',"ab123cd")
'ab@123@cd' # OK
xolox commented 10 years ago

Reviewing the documentation you seem to be correct and I wonder how I ever wrote this... Thanks for the pull request, it's now merged!