Hi, how to find and replace this?

Hi,
I’m trying to use find and replace to change a load of text. I think I need to use regular expressions but I can’t figure out which ones…

I want to get all the headings underlined and then have what’s after them on the next line.

Trying to get this:

Genesis 1:1 In the beginning God created the heavens and the earth.

Genesis 1:20 The earth was formless and void, and darkness was over the surface of the deep, and the Spirit of God was moving over the surface of the waters.

Genesis 11:3 Then God said, “Let there be light”; and there was light.

Genesis 11:40 God saw that the light was good; and God separated the light from the darkness.

To end up like this:

Genesis 1:1 (underlined)
In the beginning God created the heavens and the earth.

Genesis 1:20 (underlined)
The earth was formless and void, and darkness was over the surface of the deep, and the Spirit of God was moving over the surface of the waters.

Genesis 11:3 (underlined)
Then God said, “Let there be light”; and there was light.

Genesis 11:40 (underlined)
God saw that the light was good; and God separated the light from the darkness.

The closest I can do is use “Genesis……” as a regular expression thing, but that’s underlining more than the chapter and numbers… I need a way to select the text, but have it end at that second space, or something… Because the numbers can be 3 characters long to 5 characters long.

Cheers

1 Like

Did you used style sheets for your headings?

And please name your operating system and LibreOffice version. Thank you.

No. It’s pretty much just plain text.
Windows 10 - Libre Version: 6.4.1.2 (x64)

Trying to change plain text to plain text (accept with some underlining). It’s for pasting into apps to do Bible notes…

It is likely that you are working with direct formatting. As a result, if you want to make changes, you have to go to all the places in the document that come into question and make the changes.

You should work with styles for a somewhat larger document. For example, if you use two heading styles, you only need to make changes in two places in the appropriate styles and all headings will adjust immediately.

Please read here:

Professional text composition with Writer


If you want someone to look at your document, upload it here.

Click on the three dots ( ) below your question and click on the pencil icon to edit your question.
Inside the question click on the upload icon and upload your file. (You can also shorten your file if it is very large). Thank you.

I cant upload it, it’s copy-writed.

There’s no need to upload it anyway. All that would need to be done is copy and paste that into a blank document:

"Genesis 1:1 In the beginning God created the heavens and the earth.

Genesis 1:20 The earth was formless and void, and darkness was over the surface of the deep, and the Spirit of God was moving over the surface of the waters.

Genesis 11:3 Then God said, “Let there be light”; and there was light.

Genesis 11:40 God saw that the light was good; and God separated the light from the darkness."

Use Find and Replace to get it end up as:

"Genesis 1:1 (underlined)
In the beginning God created the heavens and the earth.

Genesis 1:20 (underlined)
The earth was formless and void, and darkness was over the surface of the deep, and the Spirit of God was moving over the surface of the waters.

Genesis 11:3 (underlined)
Then God said, “Let there be light”; and there was light.

Genesis 11:40 (underlined)
God saw that the light was good; and God separated the light from the darkness."

And then let me know the Regular Expressions used to do it. IF it’s even possible… It may not be.

The first part would be selecting the Chapter/Verses (example; “Genesis 1:20”) and then just use “Find all” and then click underline. That underlines them all.

Then would need to do the equivalent of pressing enter on each of them to make the next text start under the Chapter/Verse heading

There’s a whole load of regular expressions here; it may be able to be done:
https://help.libreoffice.org/4.4/Common/List_of_Regular_Expressions

It’s an entire Bible. I’m not editing 31,303 verses individually; unless I can help it lol.

Oh great. This comment lost it’s formatting; making it a mess.

Using Regular Expressions in Text Searches

Yeah I’ve seen it. I need someone who knows how to use regular expressions well; who can say if it’s possible or not, and if so how…

This is as close as I can get:

How about ticking Regular Expressions and:
Find: ^Genesis [:digit:]+:[:digit:]+ which finds Genesis (some numbers):(some numbers)(space) only at beginning of a paragraph
Replace: &\n which replaces the same text but with a paragraph break at the end

You will have a space at the end of the Genesis paragraph and it won’t be underlined but I’m sure you can work out how to fix that. BTW text only does not retain underlining

1 Like

Hi,
thanks. That’s way closer to what I want to do.

If i click “find all” it highlights the right characters - then I can underline them.

But then if I do “replace all”, it ends up like this:
image

Do you know how to get rid of the spaces before the sentences start please?..
Also the “replace all” adds a space before Genesis now that wasn’t there before, that needs removing…

Maybe it needs to be done in two stages with different regular expressions?.. The underlining is sorted with that set up. Now I need to do the paragraph break properly…

Ah. I missed the space after ^Genesis [:digit:]+:[:digit:]+

That’s better, but there is still just that one space after Genesis that’s wrong now…

Never-mind; I’ve sussed it out.
If I do the “replace all” first, that sorts out the paragraph break;
then do the “find all” (but remove the last space from ^Genesis [:digit:]+:[:digit:]+) to underline it, it does it perfectly.

Thanks!.. Much appreciated…