[x]Blackmoor Vituperative

Friday, 2022-04-29

Trimming trailing spaces in LibreOffice Calc

Filed under: Software,Windows — bblackmoor @ 13:39

I looked for ages before I found this advice, so I am preserving it here. Credit goes to Keyboard Playing for the original post, though.

In LibreOffice Writer, you can replace \s+(\r?(\n|$)) with $1 to remove all trailing spaces. A single execution should be efficient this time.

The regular expression (aka “regex”) can be decomposed this way:

\s+ matches one or more whitespaces;
(\r?(\n|$)) matches a carriage return (\r?\n) or the end of a paragraph (\r?$) ; \r? is there only to be compatible with Windows carriage return format;
$1 is the first captured group ((\r?(\n|$))) as it was found in the text (we put back what was found).