Regular Expression not Working

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.

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?


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.

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

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.

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 :frowning:

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

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.

Did…Search Key Not found.

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

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.

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.

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

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

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

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 ?

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.