Re: What is \1 here?
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 pointer to a helpful site for experimenting with regexes: http://pythex.org/ Cool. I also like this one, which hardly anybody appears to use: python C:\Python27\Tools\Scripts\redemo.py The functionality is virtually the same. FTR redemo.py has been removed from Python 3 at some point. -- 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
Re: What is \1 here?
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?
- 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 to a helpful site for experimenting with > regexes: http://pythex.org/ Cool. I also like this one, which hardly anybody appears to use: python C:\Python27\Tools\Scripts\redemo.py The functionality is virtually the same. -- https://mail.python.org/mailman/listinfo/python-list
Re: What is \1 here?
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): return 'spam' + matchobj.group(1) print(re.sub('(.) spam', mapper, 'x spam, y spam')) Maybe you can't tell from the reception you're getting here: People are growing tired of your questions about basic Python behavior. They want you to find a way to learn for yourself. You're asking about regular expressions. The Python docs have an extensive page detailing how they work: https://docs.python.org/3/library/re.html You need to learn how to find this stuff out for yourself. Ben Finney even gave you a pointer to a helpful site for experimenting with regexes: http://pythex.org/ -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: What is \1 here?
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
What is \1 here?
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')) -- https://mail.python.org/mailman/listinfo/python-list