Ask Your Question

Regular expression search and replace does not work - Writer

asked 2018-07-16 13:06:33 +0100

Aloraliz gravatar image


I have a very large document with a lot of lines ending with: a hyphen followed by a space followed by a line break.

I would like to remove those so that the next line moves up to complete the first line.

I realize this probably sounds confusing. I have attached a file with an example and the desired result. I hope that clarifies it.

I tried searching for "- \n" (without the quote marks) but when I try it says "search key not found". When I use "- *" the hyphen and the space are removed but the line break isn't.

Hope anyone can help.


C:\fakepath\Untitled 9.odt

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-07-16 13:23:35 +0100

In LibreOffice, regular expressions are limited to a single paragraph. The paragraph boundary (the imaginary "\n") is not affected by replacement. The only exceptions are single $ (that can be used to join all paragraphs together) and ^$ which finds empty paragraphs; these regexes are able to remove paragraph boundaries. In your case, the workaround could be replacing all newlines ($) with a unique sequence, then searching in resulting single paragraph, then replacing unique sequences left back with newlines.

edit flag offensive delete link more


If I try to search for $ I also get Search key not found.

Aloraliz gravatar imageAloraliz ( 2018-07-16 13:47:57 +0100 )edit

Is "Regular expressions" checked in Find & Replace dialog?

Mike Kaganski gravatar imageMike Kaganski ( 2018-07-16 13:56:47 +0100 )edit

It works! Thanks.

Aloraliz gravatar imageAloraliz ( 2018-07-16 14:46:32 +0100 )edit
Login/Signup to Answer

Question Tools



Asked: 2018-07-16 13:06:33 +0100

Seen: 298 times

Last updated: Jul 16 '18