Regex to match all trailing whitespace _and_ newlines.

D

Dotan Cohen

In the terrific Anki [1] application I am trying to remove trailing
whitespace from form fields. This is my regex:
[\n+\s+]$

Actually, even simplifying it to [\n] or [\r\n] is not matching any
newlines! What might be the cause of this? Note that I am not entering
the regex in Python code, I am entering it in a regex-supporting
Find/Replace dialogue in Anki. Anki is written in Python.

Thanks.

[1] ankisrs.net
 
P

Peter Otten

Dotan said:
In the terrific Anki [1] application I am trying to remove trailing
whitespace from form fields. This is my regex:
[\n+\s+]$

My attempt:
'alpha<EOL>beta<EOL><EOL>gamma<EOL>'
 
D

Dotan Cohen

Dotan said:
In the terrific Anki [1] application I am trying to remove trailing
whitespace from form fields. This is my regex:
[\n+\s+]$

My attempt:
'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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,743
Latest member
WoodrowMea

Latest Threads

Top