Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99768
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Jussi Piitulainen <harvesting@is.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: I can't understand re.sub |
| Date | Tue, 01 Dec 2015 07:28:33 +0200 |
| Organization | A noiseless patient Spider |
| Lines | 23 |
| Message-ID | <lf5r3j6ka9q.fsf@ling.helsinki.fi> (permalink) |
| References | <af27abe4-f81e-4d44-a504-c58d9e71986a@googlegroups.com> <mailman.26.1448872519.14615.python-list@python.org> <lf54mg3eupq.fsf@ling.helsinki.fi> <mailman.49.1448933226.14615.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx02.eternal-september.org; posting-host="305c68510616a2e7ac08bcd2ff1598bd"; logging-data="25486"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AOBwqNE25KtwcD6/SFIj0nm94bapX0U8=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:ktakePRsZy9L4WKar6m+VX4vrP4= sha1:NZv0sPSUuahph147iz8T21+mJfk= |
| Xref | csiph.com comp.lang.python:99768 |
Show key headers only | View raw
Erik writes: > On 30/11/15 08:51, Jussi Piitulainen wrote: [- -] >> 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 ... ;) Language processing is not what I had in mind here. Merely this, that there is some sort of word boundary, be it punctuation, whitespace, or an end of the string: >>> re.sub(r'\bspam\b', '****', 'spamalot spam') 'spamalot ****' That's not perfect either, but it's simple and might be somewhat proportional to the problem. A real solution should be aware of the actual structure of those lines, assuming they follow some defined syntax.
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