Bug 143797 - escape character \n does not work in search box for search replace in Writer
Summary: escape character \n does not work in search box for search replace in Writer
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.0.6.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-09 21:32 UTC by Federico Atristain
Modified: 2021-08-10 04:19 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Federico Atristain 2021-08-09 21:32:49 UTC
Description:
When the "\n" (without quotes) escape character is used in the search and/or search/replace dialogs it does not find the next paragraph's end.

Steps to Reproduce:
1.Open a document with several paragraphs in it
2.Open Find (Ctrl-F) or Search/Replace (Ctrl-H)
3.Enter "\n" (without quotes) to search for a paragraph end
4.Press the "Find" button

Actual Results:
The Search and Replace dialog gives an error stating: "Search key not found"

Expected Results:
The search should find the next \n (i.e. paragraph end) character after the cursor position.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Version: 7.0.6.2 (x64)
Build ID: 144abb84a525d8e30c9dbbefa69cbbf2d8d4ae3b
CPU threads: 4; OS: Windows 10.0 Build 19043; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded
Comment 1 Mike Kaganski 2021-08-09 21:55:27 UTC
> When the "\n" (without quotes) escape character is used in the search and/or
> search/replace dialogs it does not find the next paragraph's end.

And it should not. As described on the "List of Regular Expressions" help page [1], \n in the "Find" box matches *line break that was inserted with the Shift+Enter key combination*.

By the way, it (and any other regular expressions) only work when relevant option is selected in the dialog/toolbar.

To search for paragraph end, use $ as the search term (again, using regular expressions).


[1] https://help.libreoffice.org/latest/en-US/text/shared/01/02100001.html
Comment 2 Federico Atristain 2021-08-09 22:08:18 UTC
Yes, thank you.  I tried using the $ too but it does not work.

I have a document that has 2 empty paragraphs together after a full one for example (I am representing the paragraph marking with (\n)):

This is the full paragraph (\n)
(\n)
(\n)

When I do a search/replace entering in the search box:
$$$

And putting in the replace box:
\n\n

I would expect to see the result as follows:
This is the full paragraph (\n)
(\n)

This means eliminating one of the "paragraph end" markings, however, it does not work either using the \n\n\n in the search or using the $$$.

It states that it does not find it.
Comment 3 Mike Kaganski 2021-08-10 04:19:06 UTC
(In reply to Federico Atristain from comment #2)

This is because in LibreOffice, search is always *inside* a single paragraph. However, there is a way to search for an *empty* paragraph (also mentioned on the help page):

    ^$    Finds an empty paragraph.

However, for many advanced find/replace actions, you might want to use an extension: https://extensions.libreoffice.org/en/extensions/show/alternative-dialog-find-replace-for-writer