# Regular Expression not Working [closed]

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.

edit retag 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

Sort by » oldest newest most voted

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. more ## Comments Did......Search Key Not found. ( 2016-08-09 06:29:18 +0100 )edit OK. It works but I was replacing with nothing so it wasn't working as expected. ( 2016-08-13 18:11:02 +0100 )edit answered 2016-11-09 11:51:38 +0100 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 ? more ## Comments 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.

( 2016-11-09 12:16:08 +0100 )edit

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. more ## Comments 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. ( 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. ( 2016-08-08 20:01:33 +0100 )edit In the Find & Replace window, tick Other options, then tick Regular expressions. ( 2016-08-09 07:47:51 +0100 )edit I did ticked regular expressions. ^$ is not getting recognized, otherwise its working.

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

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.

more

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

( 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.

( 2016-08-13 18:05:21 +0100 )edit
1

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

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

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

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