Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80515

What is \1 here?

X-Received by 10.236.220.39 with SMTP id n37mr29194882yhp.39.1415697483003; Tue, 11 Nov 2014 01:18:03 -0800 (PST)
X-Received by 10.140.20.108 with SMTP id 99mr8943qgi.15.1415697482947; Tue, 11 Nov 2014 01:18:02 -0800 (PST)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!i13no773010qae.0!news-out.google.com!u1ni2qah.0!nntp.google.com!u7no772729qaz.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Tue, 11 Nov 2014 01:18:02 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=116.202.12.152; posting-account=ESMvWgoAAACN3co-ywvI3f_Kki2ooOjY
NNTP-Posting-Host 116.202.12.152
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <6720bebb-8263-4fb1-bcef-10dcfdc44905@googlegroups.com> (permalink)
Subject What is \1 here?
From satishmlmlml@gmail.com
Injection-Date Tue, 11 Nov 2014 09:18:02 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:80515

Show key headers only | View raw


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'))

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

What is \1 here? satishmlmlml@gmail.com - 2014-11-11 01:18 -0800
  Re: What is \1 here? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-11 10:03 +0000
  Re: What is \1 here? Ned Batchelder <ned@nedbatchelder.com> - 2014-11-11 06:52 -0500
  Re:What is \1 here? Dave Angel <davea@davea.name> - 2014-11-11 07:22 -0500
  Re: What is \1 here? Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-11 17:35 +0000

csiph-web