On Thu, Sep 1, 2011 at 13:30, Peter Otten <__pete...@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 -- http://mail.python.org/mailman/listinfo/python-list