Bug 35250 - EDITING: Search/Replace with [:cntrl:] as sub-expression fails
Summary: EDITING: Search/Replace with [:cntrl:] as sub-expression fails
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Find-Search
  Show dependency treegraph
 
Reported: 2011-03-12 06:08 UTC by Andreas Wagner
Modified: 2021-06-28 14:17 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
document to test regex search and replace (8.80 KB, application/vnd.oasis.opendocument.text)
2021-06-28 14:16 UTC, stragu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Wagner 2011-03-12 06:08:55 UTC
I have a document where footnotes come before periods, commas and the like, and I want to swap them. Thus I open a search/replace dialogue where I search for ([:cntrl:])([.,;:]), and this correctly retrieves all those occurences.
But whatever I enter in the replace field ($2$1, \2\1, $1$0, &2&1, even & ...) it gets inserted as plaintext (i.e. "$2$1" etc.), not as the pattern to which it should refer.

(The replace expression $2$1 does what it is supposed to do when I'm searching for something without a control character, like (.)([,.;:]): Then it is correctly swapping the arbitrary character and the punctuation. But this does not work when searching for ([:cntrl:])([,.;:]) - in that case, while correctly retrieving and selecting the relevant occurences, it replaces them with literal $2$1. With just & as a replace expression the same happens, both the footnote and the punctuation are replaced with a literal "&".)

BTW, this has been present in OOo, too: http://openoffice.org/bugzilla/show_bug.cgi?id=101068 (and possibly http://openoffice.org/bugzilla/show_bug.cgi?id=15666).
Comment 1 Björn Michaelsen 2011-12-23 11:45:54 UTC Comment hidden (obsolete)
Comment 2 Florian Reisinger 2012-08-14 13:59:14 UTC Comment hidden (obsolete)
Comment 3 Florian Reisinger 2012-08-14 14:00:27 UTC Comment hidden (obsolete)
Comment 4 Florian Reisinger 2012-08-14 14:05:08 UTC Comment hidden (obsolete)
Comment 5 Florian Reisinger 2012-08-14 14:07:11 UTC Comment hidden (obsolete)
Comment 6 Andreas Wagner 2013-12-17 10:00:21 UTC
Finally got round to see if the issue is solved in the meantime. But it isn't (v 4.1.3.2).
Here is a new attempt, and a new description based on the hints in the current bugtracker template:

If you do Search and Replace and want to re-use one of the matches in the replace expressions, this fails if the match was a [:cntrl:] Control code.

Steps to reproduce:
1. Enter a text with footnotes: bla¹. bleh². foo.³
2. Open the Search and Replace dialog
3. Under further options, select "Use regular expressions"
4. In the "Search for" field, enter "([:cntrl:])(\.)" (without the quotes)
5. In the "Replace with" field enter "$2$1" (without the quotes)
6. Klick on "Replace all"


Expected behavior:
All footnote signs preceding periods are matched (no. 1 and 2); these are replaced with first and second match inversed, i.e. period and footnote sign: bla.¹ bleh.² foo.³


Current behavior:
The matching works fine, but the $1 seems to be empty. The resulting text is: bla. bleh. foo.¹
Comment 7 Joel Madero 2014-11-04 03:05:55 UTC
Never confirmed by QA team, REOPENED is incorrect status, marking as UNCONFIRMED.
Comment 8 Buovjaga 2014-11-15 18:07:53 UTC
(In reply to Andreas Wagner from comment #6)
> Steps to reproduce:
> 1. Enter a text with footnotes: bla¹. bleh². foo.³
> 2. Open the Search and Replace dialog
> 3. Under further options, select "Use regular expressions"
> 4. In the "Search for" field, enter "([:cntrl:])(\.)" (without the quotes)
> 5. In the "Replace with" field enter "$2$1" (without the quotes)
> 6. Klick on "Replace all"
> 
> 
> Expected behavior:
> All footnote signs preceding periods are matched (no. 1 and 2); these are
> replaced with first and second match inversed, i.e. period and footnote
> sign: bla.¹ bleh.² foo.³
> 
> 
> Current behavior:
> The matching works fine, but the $1 seems to be empty. The resulting text
> is: bla. bleh. foo.¹

Reproduced.

Win 7 64-bit Version: 4.4.0.0.alpha2+
Build ID: b021b5983c62e266b82d9f0c5c6d8d8900553827
TinderBox: Win-x86@39, Branch:master, Time: 2014-11-12_01:10:08
Comment 9 QA Administrators 2015-12-20 16:15:44 UTC Comment hidden (obsolete)
Comment 10 Andreas Wagner 2015-12-27 00:01:38 UTC
I have just re-confirmed the bug with identical behaviour in version/build 5.0.4.2 Arch Linux build-2. And it is inherited from OOo, I have reported it for OOo 3.0.1 back in 2009.
Comment 11 QA Administrators 2017-01-03 19:55:03 UTC Comment hidden (obsolete)
Comment 12 Andreas Wagner 2017-01-04 20:05:39 UTC
I have again re-confirmed the bug with identical behaviour in Version: 5.2.4.2.0+, Build-ID: 5.2.4-1.
CPU-Threads: 2; BS-Version: ArchLinux 4.8. And it is inherited from OOo, I have reported it for OOo 3.0.1 back in 2009.
Comment 13 QA Administrators 2018-11-07 04:01:36 UTC Comment hidden (obsolete)
Comment 14 Andreas Wagner 2018-11-07 09:02:41 UTC
I have again re-confirmed the bug with identical behaviour in Version: 6.0.6.2, Build-ID: 6.0.6-5.
CPU-Threads: 8; BS: [Arch]Linux 4.18; UI-Render: Standard; VCL: gtk3;
Gebietsschema: de-DE (de_DR.UTF-8); Calc:group

And it is inherited from OOo, I have reported it for OOo 3.0.1 back in 2009. 

(Just out of curiosity: Is there maybe some kind of prize for the oldest unfixed bug?)
Comment 15 QA Administrators 2019-11-08 03:38:45 UTC Comment hidden (obsolete)
Comment 16 stragu 2021-06-28 14:16:50 UTC
Created attachment 173247 [details]
document to test regex search and replace

Adding an example document for easy testing.

Reproduced in:

Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: f446a203fa2897bab8ae7686c948a8bf060675c6
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2021-06-24_15:16:38
Calc: threaded
Comment 17 stragu 2021-06-28 14:17:35 UTC
Marking as affecting All OSs, as per Comment 8.