Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99762
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Erik <python@lucidity.plus.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: I can't understand re.sub |
| Date | Tue, 1 Dec 2015 01:26:11 +0000 |
| Lines | 25 |
| Message-ID | <mailman.49.1448933226.14615.python-list@python.org> (permalink) |
| References | <af27abe4-f81e-4d44-a504-c58d9e71986a@googlegroups.com> <mailman.26.1448872519.14615.python-list@python.org> <lf54mg3eupq.fsf@ling.helsinki.fi> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de jNusbIIgIeuesgj4JHVVcwhOMaCNHbtq/qLfPIqFsV+g== |
| Return-Path | <python@lucidity.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.055 |
| X-Spam-Evidence | '*H*': 0.89; '*S*': 0.00; '(but': 0.15; 'argument': 0.15; 'from:addr:python': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'substitute': 0.16; 'wrote:': 0.16; 'say,': 0.18; 'language': 0.19; '>>>': 0.20; 'do.': 0.22; 'decide': 0.23; 'leave': 0.23; '(or': 0.23; 'header:In-Reply- To:1': 0.24; 'all.': 0.24; 'header:User-Agent:1': 0.26; 'example': 0.26; 'other,': 0.29; 'spaces': 0.29; 'fixed': 0.31; 'option': 0.31; 'received:84': 0.32; 'third': 0.33; 'foo': 0.33; 'surely': 0.33; 'know.': 0.34; 'text': 0.35; 'replace': 0.35; 'quite': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'say': 0.37; 'wanted': 0.37; 'no,': 0.38; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'show': 0.62; 'charset:windows-1252': 0.62; 'to,': 0.63; 'wish': 0.71; 'useful.': 0.72; 'attractive': 0.79; '"spam"': 0.84; 'spammer': 0.84 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=JN/GyJ+b c=1 sm=1 tr=0 a=Ypmeq7T0cKALDUsRPCToMg==:117 a=Ypmeq7T0cKALDUsRPCToMg==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=N659UExz7-8A:10 a=v8-QU5VCdR45x0KiVEcA:9 a=pILNOxqGKmIA:10 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
| In-Reply-To | <lf54mg3eupq.fsf@ling.helsinki.fi> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:99762 |
Show key headers only | View raw
On 30/11/15 08:51, Jussi Piitulainen wrote:
> Surely the straight thing to say is:
>
> >>> foo.replace(' CONTENT_PATH ', ' Substitute ')
> 'foo bar baz spam Substitute bar spam'
Not quite the same thing (but yes, with a third argument of 1, it would be).
> But there was no guarantee of spaces around the target.
I know. It was just an example to show that there might be an option
that's not a regex for the specific use indicated. It's up to the OP to
decide whether they think the spaces (or any other, or no, delimiter)
would actually be required or useful. Or whether they really prefer a
regex after all.
> If you wish to,
> say, replace "spam" in your foo with "REDACTED" but leave it intact in
> "May the spammer be prosecuted", a regex might be attractive after all.
But that's not what the OP said they wanted to do. They said everything
was very fixed - they did not want a general purpose human language text
processing solution ... ;)
E.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
I can't understand re.sub Mr Zaug <matthew.herzog@gmail.com> - 2015-11-29 13:36 -0800
Re: I can't understand re.sub Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-29 22:01 +0000
Re: I can't understand re.sub Mr Zaug <matthew.herzog@gmail.com> - 2015-11-29 17:20 -0800
Re: I can't understand re.sub Rick Johnson <rantingrickjohnson@gmail.com> - 2015-11-29 17:12 -0800
Re: I can't understand re.sub Mr Zaug <matthew.herzog@gmail.com> - 2015-11-29 17:24 -0800
Re: I can't understand re.sub Erik <python@lucidity.plus.com> - 2015-11-29 21:53 +0000
Re: I can't understand re.sub Jussi Piitulainen <harvesting@is.invalid> - 2015-11-30 10:51 +0200
Re: I can't understand re.sub Erik <python@lucidity.plus.com> - 2015-12-01 01:26 +0000
Re: I can't understand re.sub Jussi Piitulainen <harvesting@is.invalid> - 2015-12-01 07:28 +0200
Re: I can't understand re.sub Erik <python@lucidity.plus.com> - 2015-12-01 21:31 +0000
csiph-web