# 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

edit retag close merge delete

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?

( 2019-11-18 13:24:12 +0100 )edit

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

( 2019-11-18 15:14:02 +0100 )edit

Sort by » oldest newest most voted

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:

• Last line contains 2 paragraphs
• Your file matches exactly the definition made in your question and my comment (Do not even consider to use the procedure if there is any deviation from the 4 verse lines + 1 empty paragraph line pattern.)
• You have extension https://extensions.libreoffice.org/ex... installed.
• You ticked [x] Regular expressions with Alternative Find & Replace dialog

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.

C:\fakepath\Verses-v05-No-Symbol-Quote-after-Number-RePara.odt

more

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? C:\fakepath\Screenshot from 2019-11-18 22-39-18.png

( 2019-11-18 23:27:59 +0100 )edit

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.

( 2019-11-18 23:41:28 +0100 )edit

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/1...

( 2019-11-18 23:53:04 +0100 )edit

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?

( 2019-11-19 00:07:25 +0100 )edit

You're a genius it worked!!

( 2019-11-19 00:28:20 +0100 )edit

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

( 2019-11-19 09:05:08 +0100 )edit

If I had earlier seen your poem as described in your last upload (https://ask.libreoffice.org/upfiles/1...) 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 @Opaque did the job brilliantly on Writer/AltSearch.oxt. I additionally upvoted him, awesome helper!

( 2019-11-19 12:26:47 +0100 )edit