Re: What is \1 here?

2014-11-11 Thread Mark Lawrence
On 11/11/2014 15:20, Albert-Jan Roskam wrote: - Original Message - From: Ned Batchelder To: python-list@python.org Cc: Sent: Tuesday, November 11, 2014 12:52 PM Subject: Re: What is \1 here? You need to learn how to find this stuff out for yourself. Ben Finney even gave you a

Re: What is \1 here?

2014-11-11 Thread Denis McMahon
On Tue, 11 Nov 2014 01:18:02 -0800, satishmlmlml wrote: > What does \1 do in the following piece of code(fourth line)? It tells you to learn about regex. http://www.pcre.org/pcre.txt -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: What is \1 here?

2014-11-11 Thread Albert-Jan Roskam
- Original Message - > From: Ned Batchelder > To: python-list@python.org > Cc: > Sent: Tuesday, November 11, 2014 12:52 PM > Subject: Re: What is \1 here? > You need to learn how to find this stuff out for yourself. Ben Finney > even gave you a pointer

Re: What is \1 here?

2014-11-11 Thread Ned Batchelder
On 11/11/14 4:18 AM, 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):

Re: What is \1 here?

2014-11-11 Thread Mark Lawrence
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):

What is \1 here?

2014-11-11 Thread satishmlmlml
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('(