Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80518
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: What is \1 here? |
| Date | 2014-11-11 10:03 +0000 |
| References | <6720bebb-8263-4fb1-bcef-10dcfdc44905@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15655.1415700238.18130.python-list@python.org> (permalink) |
On 11/11/2014 09:18, satishmlmlml@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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