Ask Your Question

Regular Expression not Working [closed]

asked 2016-08-08 09:01:32 +0100

Gameranand gravatar image

updated 2020-09-15 12:12:24 +0100

Alex Kemp gravatar image

I converted a PDF file into a ODT file and there are just too many linebreaks (Enter not Shift+Enter). Now I want to remove them all so that it doesn't look awkward. I tried Search and Replace and Alt Search and Replace as well. They always search for line breaks (Shift+Enter) so not recognizing the breaks that I want them to.

I also tried the Autocorrect option to combine line breaks if they are 40% or more but that didn't worked out either.

Now could you guys please guide me how I go about it. image description

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-09-15 12:12:38.285893

4 Answers

Sort by » oldest newest most voted

answered 2016-08-08 11:18:19 +0100

floris v gravatar image

updated 2016-11-09 12:17:25 +0100

Take care when you find a way to get rid of all paragraph breaks - OpenOffice, and therefore LibreOffice, introduced a 64 K paragraph length limit that has, as far as I know, not yet been removed or changed. So if you do get rid of all paragraph breaks in a document with more than 64 K characters, you can suffer data loss.

EDIT The max paragraph length has been increase to 2^32, so no worries.

$ for a paragraph break worked for me.

edit flag offensive delete link more


Did......Search Key Not found.

Gameranand gravatar imageGameranand ( 2016-08-09 06:29:18 +0100 )edit

OK. It works but I was replacing with nothing so it wasn't working as expected.

Gameranand gravatar imageGameranand ( 2016-08-13 18:11:02 +0100 )edit

answered 2016-08-08 13:57:00 +0100

paul1149 gravatar image

From your screen cap, it looks like you have double linefeeds between actual paragraphs. That is fortunate. You can achieve what you want in three steps.

With Regular Expressions enabled:

  1. Search for ^$ and replace with qqq
  2. Search for $ and replace with a space
  3. Search for qqq and replace with \n

You might have to clean up double spaces afterward. For empty lines search ^$ and replace with nothing.

edit flag offensive delete link more


Could you please tell me what they do exactly. I wanna learn this thingy and I can understand because I have studied Regular expression. I just don't know the symbols.

Gameranand gravatar imageGameranand ( 2016-08-08 18:26:28 +0100 )edit

It gives the error "Search Key not found" which was previous error when I tried as well.

Gameranand gravatar imageGameranand ( 2016-08-08 20:01:33 +0100 )edit

In the Find & Replace window, tick Other options, then tick Regular expressions.

floris v gravatar imagefloris v ( 2016-08-09 07:47:51 +0100 )edit

I did ticked regular expressions. ^$ is not getting recognized, otherwise its working.

Gameranand gravatar imageGameranand ( 2016-08-13 18:10:20 +0100 )edit

answered 2016-08-08 10:52:28 +0100

Regina gravatar image

updated 2016-08-10 00:06:02 +0100

From the help topic "List of Regular Expressions"

$ on its own matches the end of a paragraph. This way it is possible to search and replace paragraph breaks.

Have you tried it?

screenshot of the needed settings in the Find & Replace dialog Only to be sure we mean the same dialog, I have attached a screen shot of the dialog. Start with clicking 'Replace' several times, to see what happens.

edit flag offensive delete link more


Yes, I have tried it. Didn't work.

Gameranand gravatar imageGameranand ( 2016-08-09 06:29:57 +0100 )edit

Yes it does work. Now the problem is that I need to have the paragraph format intact for headings. For example it ignores Preface as in my screenshot and everything is together which makes it difficult for formatting. One solution is that I'll have to do selection replace with this expression. Is there any other method so that it doesn't break the format ??

First I was replacing with nothing thats why it wasn't working I guess.

Gameranand gravatar imageGameranand ( 2016-08-13 18:05:21 +0100 )edit

I have used selections. Do not select the last paragraph before the heading and not the heading itself. And you cannot use multi-selections, but the selected range has to be continuous :(

Regina gravatar imageRegina ( 2016-08-14 12:53:25 +0100 )edit

Its problematic but still atleast its something to work. Thanks. :)

Gameranand gravatar imageGameranand ( 2016-08-14 17:56:50 +0100 )edit

answered 2016-11-09 11:51:38 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I have the same problem as Gameranand. They are described in "Please check the new "regular expressions" in WRITER version 5.1". They are yet not solved. They were caused by a switch to new "regular expressions" in version 5.1. Who can help to reestablish the old terms, which were much more useful ?

edit flag offensive delete link more


You can only revert to an older version, there's no way to turn use of the new expressions off.

I just tried and ^$ is found. Make sure that you don't have any other (hidden) things to search for, like formatting, that might cause a mismatch.

floris v gravatar imagefloris v ( 2016-11-09 12:16:08 +0100 )edit

Question Tools

1 follower


Asked: 2016-08-08 09:01:32 +0100

Seen: 1,244 times

Last updated: Nov 09 '16