Find and replace multiline text by Regular Expressions

Hello community,
I am looking to find and replace some text in a document, but so far, I haven’t been able to figure out how to search across more than one line. Is this even possible?
Here’s an example of what I have in the document in several modifications:

“groupNames”: [
“xyz”,
“xyz”
]

I need to find these few lines as a whole, but “xyz” could be anything, so (.*). My issue is that I am not able to search through multiple lines.

What I need to achieve is:

"groupNames": [ ]

Can you please help me with that? Thank you very much.

Built-in Find & Replace is limited to one paragraph. You can find and replace anything as long as your target is fully contained in a single paragraph.

If your text to find spans several paragraph, built-in F&R will not find it.

You must install an extension like AltSearch to work around this limitation.

You didn’t describe thoroughly your data in your question. This looks like JSON as a key-value pair. To reflect the “atomic” nature of the pair, I’d enter it in a single paragraph (delimited by Enter). If you want to “format” the value attribute, you can use line breaks (entered as Shift+Enter). This structures your data the same as its logical meaning (semantics). The full key-value is now a single paragraph and built Find & Replace works.

PS: when asking here, always mention OS name, LO version (all 4 numbers) and save format. When posting screenshots, enable View>Formatting Marks so that we see how your data is “structured”.

Thank you for the prompt answer.

Apologies for the missing information:

  • Operating System: Fedora 39
  • LibreOffice Version: 7.6.4.1
  • Format: I do not save it, as I want to use LibreOffice just to modify text and copy it outside.

The content is actually JSON in a key-value format exported from openHAB. Editing it in Writer as a batch seems to be more effective for me.

Now I understand why I was not able to find multiple lines. Once I changed the paragraph break to a line break, I was able to locate all lines. It is a bit tricky to replace paragraph breaks with line breaks; I did it the way it is suggested in this post. Is there a better way?

I understand you want to process a plain text file and get a plain text file on output. Then LO Writer is not the adequate tool. Depending on your skill/knowledge, you can create various scripts to be launched as command lines in a terminal. You didn’t mention your desktop (common desktops are Gnome or Plasma KDE – I installed the latter). However you don’t seem to be up-to-date because my Fedora 39 already is at LO 7.6.4.2, but this is not relevant here.


You can go for a bash script subcontracting the effective edit to sed. Alternatively, you can try to write a Perl script. Perl provides a more comprehensive regexp engine then sed. If you’re not afraid, (g)awk could also provided the capability you’re looking for.


Writer is intended to achieve a nice-looking layout of text not to process data. In your case, plain text has no notion of “paragraphs”. Plain text is just a sequence of characters broken into lines. How lines are delimited is OS-dependent. This is why it is important to use tools which hide these idiosyncrasies. Perl is my favourite for complex regexp, sed for simple replacement. When processing is very sophisticated, I’d use macro-generators.

if your goal is processing json you should use a library like python json

It’s weird with the LibreOffice version because I have a fully updated system, and LibreOffice is not on hold or anything. By the way, I use GNOME.

Thank you for all the hints and recommendations. I am quite a novice in scripting, so for my purposes, it is pretty straightforward and effective to do it in LibreOffice. I just need to replace and/or remove some keys, and it works perfectly this way.

After making modifications in LibreOffice, I simply use some online JSON tools to validate and copy to the clipboard in the proper way.

Thank you for the hint; in the end, I used some online tools.