Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #14417
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <dotancohen@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; '>>>>': 0.09; 'internally': 0.09; 'skip:\\ 10': 0.09; 'trailing': 0.09; 'newlines': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'thanks,': 0.18; 'received:74.125.82.174': 0.19; 'received:mail- wy0-f174.google.com': 0.19; 'cc:no real name:2**0': 0.20; 'trying': 0.21; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'sep': 0.23; 'thu,': 0.28; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.30; 'html.': 0.30; 'sub': 0.30; 'whitespace': 0.30; "skip:' 10": 0.30; 'stores': 0.34; 'model': 0.37; 'received:74.125.82': 0.38; 'received:google.com': 0.38; 'subject:: ': 0.39; 'received:74.125': 0.39; 'url:co': 0.63; 'otten': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=HrbxBxQJ+jfn91xVabxggfIFbWftuh7XTPbUaRrkQq0=; b=i2ygPc4kNxySubTs/gpCnJPJGgAWxG+d4M3qKgBWfDaosZ+uhzmw7sZnNkOILiMfiF 9O64NoxmIY6QesSkEv27udBr8TL7n2t/Ff+AHAnx8G8G5k5SVaRRSTRGYqTTPYMnWL/s rM0pT1BMsVB2WWBBDa6V53dfb+bZ9mnAfgjN4= |
| MIME-Version | 1.0 |
| In-Reply-To | <j3nmqm$vp4$1@solani.org> |
| References | <mailman.653.1314870127.27778.python-list@python.org> <j3nmqm$vp4$1@solani.org> |
| Date | Tue, 11 Oct 2011 00:23:35 +0200 |
| Subject | Re: Regex to match all trailing whitespace _and_ newlines. |
| From | Dotan Cohen <dotancohen@gmail.com> |
| To | Peter Otten <__peter__@web.de> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1871.1318285416.27778.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1318285416 news.xs4all.nl 2487 [2001:888:2000:d::a6]:47998 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:14417 |
Show key headers only | View raw
On Thu, Sep 1, 2011 at 13:30, Peter Otten <__peter__@web.de> wrote:
> Dotan Cohen wrote:
>
>> In the terrific Anki [1] application I am trying to remove trailing
>> whitespace from form fields. This is my regex:
>> [\n+\s+]$
>
> My attempt:
>
>>>> sub = re.compile(r"\s*?(\n|$)").sub
>>>> sub("<EOL>", "alpha \nbeta \r\n\ngamma\n")
> 'alpha<EOL>beta<EOL><EOL>gamma<EOL>'
>>>> sub("<EOL>", "alpha \nbeta \r\n\ngamma")
> 'alpha<EOL>beta<EOL><EOL>gamma<EOL>'
>>>> sub("<EOL>", "alpha \nbeta \r\n\ngamma\t")
> 'alpha<EOL>beta<EOL><EOL>gamma<EOL>'
>
Hi Peter, sorry for the _late_ reply.
It turns out that Anki stores newlines internally as <br>, since its
display model is based on HTML. Thanks, though!
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Regex to match all trailing whitespace _and_ newlines. Dotan Cohen <dotancohen@gmail.com> - 2011-09-01 12:42 +0300
Re: Regex to match all trailing whitespace _and_ newlines. Peter Otten <__peter__@web.de> - 2011-09-01 12:30 +0200
Re: Regex to match all trailing whitespace _and_ newlines. Dotan Cohen <dotancohen@gmail.com> - 2011-10-11 00:23 +0200
csiph-web