On 11/11/2014 09:18, satishmlm...@gmail.com wrote:
What does \1 do in the following piece of code(fourth line)? import re print(re.sub('[ABC]', '*', 'XAXAXBXBXCXC')) print(re.sub('[ABC]_', '*', 'XA-XA_XB-XB_XC-XC_')) print(re.sub('(.) spam', 'spam\\1', 'x spam, y spam')) def mapper(matchobj): return 'spam' + matchobj.group(1) print(re.sub('(.) spam', mapper, 'x spam, y spam'))
What did your last skivvy die of, overwork? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list