Replacing paragraph with manual line break after a page break

I’ve tried to enter $ as a regular expression in the search box and it works like a charm.
But it matches both a manual line break or a manual page break, while I’m looking a way to match them separately.

Then I’ve also read that ^p as a regular expression in the replace means a paragraph sign and I must enter the unicode.
I’ve seen how to type unicode with Alt+X but it doesn’t work in the replace box. And, furthermore, Alt+X doesn’t work with the manual line break (Shift+Enter) even in document body. However I can copy paste the manual line break from the body of document body to the replace box. But am I supposed to do like that?

And how can I match a manual page break in the search regular expression?
I’ve tried with \m (and regular expression marked) but it doesn’t work.

I’m on Fedora 31 and LibreOffice version is

Version: 6.3.5.2
Build ID: 6.3.5.2-1.fc31
CPU threads: 4; OS: Linux 5.5; UI render: default; VCL: gtk3; 
Locale: en-US (en_US.UTF-8); UI-Language: en-US
Calc: threaded

Thank you

A remark, not an answer.

Breaks are not Unicode characters. They are “abstractions” (formatting instructions you give to Writer) encoded in complex XML. In regular expressions they are represented by various symbols, such as $ and there is a lot of backstage work to match them to the XML (or other internal representation). This is why copying them from text into the search boxes does not work.

Only the manual line break can be considered equivalent to a character \n or U+000A.

@ajlittoz The problem however is that \n in the replace text (of the standard search&replace) does not correspond to U+000A but to a paragraph sign and even in the body of the document the Alt+X replacement does not work with \n. Regarding the point that “there is a lot of backstage to match them to the XML”, I know and indeed I also opened a question regarding python docx, that does not seem to work either [question] Can't find page breaks in an existing document · Issue #823 · python-openxml/python-docx · GitHub

On the other hand, the alternative Find & Replace is really super!

Yes, there is a huge difference between the Search box and the Replace box. They have slightly different encodings for the abstractions ($ in Search is only a location while \n in Replace is a full paragraph descriptor).

Your remark about manual line break in the body is correct. I didn’t want to embark into subtlety not knowing your awareness level.

About your question, I don’t know for docx, but in Writer, pages do not exist until there needs to lay out text on them. Consequently, there is no boundary information in the document. You can only find the requests for manual page breaks.

\m does not appear to work in the standard LO search and replace function on its own.

Alternative Find & Replace / (AltSearch) extension works and has a number of other useful regular expressions listed for selection.

Using the extension; to remove manual page breaks can use:

Search: \m

Replace: \A{BreakType=0}

Using the extension; to remove manual page breaks and replace them with some text:

Search: \m

Replace: \A{BreakType=0}REPLACEMENT_TEXT_HERE (no space needed between } and R)

Also, .* regex which matches paragraphs and does not seem to include manual line breaks which may be a better option for your purpose.

alternative_find_and_replace_extension

There is also a reasonably good help file accessible by the ? icon

If this answer helped you, please accept it by clicking the check mark :heavy_check_mark: to the left and, karma permitting, upvote it. That will help other people with the same question. In case you need clarification, edit your question (not an answer) or comment the relevant answer.

Thank you very much! Let me try and accept your answer. At first sight is funny that this is called “alternative”: so it should be the regular one, installed in the package, I wonder why it is not so, out of my curiosity. Ok, I’m going to install it.

Yes it works and \m matches the manual page break. I wanted to match a page break followed by a line of text ended by a manual line break and this is ok: \m(.*)\n. Wow, and I can replace it with \m\1\p Perfect! Even better than windows word, that does not accept \p in the replace text! (https://stackoverflow.com/a/61636547/11323942)