Bug 157303 - Calc Search&Replace: support the \n (new line) in Replace when "Regular Expression" is on, as in Writer
Summary: Calc Search&Replace: support the \n (new line) in Replace when "Regular Expre...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.5.0.3 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL: https://ask.libreoffice.org/t/find-an...
Whiteboard:
Keywords:
Depends on:
Blocks: Find-Search
  Show dependency treegraph
 
Reported: 2023-09-18 09:06 UTC by m_a_riosv
Modified: 2024-06-22 13:13 UTC (History)
3 users (show)

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 m_a_riosv 2023-09-18 09:06:29 UTC
Actually, the new line \n with Replace (Search & Replace) it passed as literal.
https://help.libreoffice.org/latest/en-US/text/shared/01/02100001.html?DbPAR=SHARED#bm_id3146765

\n
When entered in the Replace text box in Writer, inserts a paragraph break that can be inserted with the Enter or Return key.
It has no special meaning in Calc, and is treated literally there.

Modify it in Calc to work the same as in Writer, creating a new line.
Comment 1 ady 2023-09-18 21:57:19 UTC
(In reply to Mike Kaganski from tdf#43107 comment #26)
> (In reply to DN from tdf#43107 comment #20)
> > The content of "replace" should be interpreted as a regex (i.e.
> > \n should be interpreted as a newline, not a literal string).
> 
> I want to stress that
> it's incorrect to consider *replacement* string as a "regex" - no, it is
> never so.

It is probably worth reading the entire original comment (and probably also those prior to it).

IDK whether that statement from Mike means that this RFE is not adequate.
Comment 2 m_a_riosv 2023-09-19 16:11:18 UTC
In Mike comments, he said the behavior should be the same as Writer, only calling it regex it's not fine.
Comment 3 Stéphane Guillou (stragu) 2023-10-02 12:10:58 UTC
Mike seems to agree that it should be made consistent with Writer:

(In reply to Mike Kaganski from bug 43107 comment #26)
> I would argue that for consistency, exactly because in Calc, the
> newline in a cell inserts *paragraphs* (not only available in the file
> format, but also in the API; and that is not a bug), the \n in the
> replacement box should behave *consistently* with Writer, where it inserts
> paragraphs.
I think it makes sense too. -> New
(or did I misunderstand your point, Mike?)

Let's say this "started" in 7.5 as a follow-up to the documentation fix for bug 43107.

Confirmed that replacing <some_chars> with \n in Calc does not work as one would expect with "Regular Expressions" on.

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: e9a0c97de95688b2f86bbb4dd8c823af5442401c
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

But in my (rather uninformed?) opinion, the whole thing should be made consistent across components with the wider-ranging change of:
- making $ work in both search and replace for paragraph breaks
- making \n work in both search and replace for line breaks
... and the distinction between the two would only matter in Writer (where both <text:line-break/> and <text:p> exist)

Would solve many headaches in my opinion.