Complex finding and adding- might not be possible?

i have a poem with 200 hundred verses
each verse has four lines
between each verse there is one line space

I need to add a double quote character - " - before the 1st character of the first line of each verse and after the last character of the 4th line of each verse.

is it possible?

Thank you

Screenshot from 2019-11-18 22-39-18.pngGuide to the Middle Way prepared for Memorize Now.odt

Some missing information - I assume:

  1. Each line of a verse is a paragraph (indicated by a pilcrow character if View -> [x] Formatting Marks is activated at the end of a line). In other words: There a four paragraphs per verse.
  2. One line space is an empty paragraph (indicated by a single pilcrow character)

Right?

Do you have a spying agent on my machine? :slight_smile:
Yes you are spot on

Hello,

the following works for me (I strongly recommend you make a working copy of your file and you work on the copy and you have View -> [x] Formatting Marks ticked).
The idea is:

  1. Replace the paragraph marks with text by a line feed
  2. Replace text within a verse as per requirements (first line to start with " and last line to end with "
  3. Optional: Replace line feed by paragraphs

Prerequisites:

Step 1: Replace the paragraph marks with text by a line feed

Search for: (.+)\p
Replace: \1\n

The following screenshot shows the result after the replacement:

Step 2: Replace text within a verse as per requirements (first line to start with " and last line to end with ")

Search for: (.+)\n(.+)\n(.+)\n(.+)\n\p
Replace: "\1\n\2\n\3\n\4"\n\p

The following screenshot shows the result after the replacement:

Step 3: Optional: Replace line fed by paragraphs

Search for: \n
Replace: \p

The following screenshot shows the result after the replacement:

Remark Tried to figure out more sophisticated pattern, but got none working. May be due to my own ignorance (most probably) or may be the AltSearch is not working the way it should (e.g. can’t get it working using (.*) patterns, this used (.+), which worked.

Tested using LibreOffice:

Version: 6.3.3.2, Build ID: a64200df03143b798afd1ec74a12ab50359878ed
CPU threads: 8; OS: Linux 4.12; UI render: default; VCL: kde5;
Locale: en-US (en_US.UTF-8); UI-Language: en-US, Calc: threaded

Update Please see the following file, which contains the double quotes at the beginning of the text (after the number) and all of the " ❖ " symbols removed.

Verses-v05-No-Symbol-Quote-after-Number-RePara.odt

Many thanks for the effort. I truly appreciate it.
I add a screen shot to my original question (becasue i cant see how to add a screen shot inside this comment) it shows that I did not get much luck with finding the expression (.+)\p
Any suggestions?
Screenshot from 2019-11-18 22-39-18.png

This is because you did not mention the special characters and numbers at the beginning of the verses in your question. The only advice i could give further is to upload your file, because from a screenshot I cannot extract any character and make a proper test.

appologies for the misinformation.
i cleared the special character at the begining of the lines.
and there is some progress!! the initial expression seems to work and i seem to get some good results on replacing with the \1\n
As it is late for me now i am going to continue tomorrow.
many thanks.
i hope this link has the document and any help you offer is greatly appreciated.
many thanks
https://ask.libreoffice.org/upfiles/1574117523652097.odt

Finally not all of the empty paragraphs are really empty, but contain a space. And where do you really want the the double quote " at the beginning of a verse. In front of the number or after the number?

You’re a genius it worked!!

I want the " as the very first character;
I cleared the spaces.
Your solution worked perfect.
Many thanks

If I had earlier seen your poem as described in your last upload (https://ask.libreoffice.org/upfiles/1574117523652097.odt) I would hava offered you another idea: copy/paste into Calc and then work on Data/Filter. 1st and 4th line could easily be detected/filtered and then separately edited. But @anon73440385 did the job brilliantly on Writer/AltSearch.oxt. I additionally upvoted him, awesome helper!