Bug 102374 - Find & Replace - the \t wildcard is not parsed as a replacement string for some Find instances
Summary: Find & Replace - the \t wildcard is not parsed as a replacement string for so...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: high minor
Assignee: Justin L
URL:
Whiteboard: target:6.1.0 target:6.0.2
Keywords:
: 107429 (view as bug list)
Depends on:
Blocks: 38261 Find-Search Find&Replace-Dialog
  Show dependency treegraph
 
Reported: 2016-09-22 20:48 UTC by shcothran
Modified: 2021-03-13 17:09 UTC (History)
9 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 shcothran 2016-09-22 20:48:07 UTC
Is similar to 37494 and I agree with 38261 but this is specific to Writer and using a regular expression in the Replace field.

I am trying to change the end of paragraph (reg exp $) with a tab (\t)  It finds the end of paragraph just fine when I put the $ into the Find field and have regular expression checkbox on.  I put \t into the Replace field and it changes the end of paragraph to a slash and a t.    I have tried different regular expressions in the Find field and all that I have tried seem to work.  I have tried \t, \n, \u0009, \x09 in the Replace field and each time I get the characters, as if the regular expression box was not checked.  I read another post that said that Replace ALL worked when Replace did not.  I tried that also but still got characters.

O a;sp tried copying a tab from somewhere else in the document and pasting it into the Replace field.  Did not work.

Did finally find a workaround but it does not eliminate the bug.  Workaround:  
1.  Manually place a Tab in the document.
2.  Select and Copy that Tab.
3.  Select area to be searched.  
4.  open Find and Replace dialog box.  
5.  Type in $ in Find field.  
6.  Make sure Current Selection and Regular Expression boxes are checked.  
7.  Click FIND ALL.
8.  CTRL-V to paste the copied Tab into all the Find All places.
Comment 1 RGB 2016-10-02 09:43:44 UTC
Confirmed on 5.1 and 5.2: \t on the "replace by" box with RegExp enabled gives a \t instead of a tab. Other RegExp still work on "replace", like \n, but \t does not even if help says it should

https://help.libreoffice.org/Common/List_of_Regular_Expressions
Comment 2 temuchin 2016-10-16 19:38:23 UTC
Same problem found in version
Version: 4.2.8.2
Build ID: 420m0(Build:2)

also noticed that if I go to replace ;$ (semicolon followed by eol) with ; (semicolon space) it will replace semicolon eol with space eol, leaving the EOL.
Comment 3 V Stuart Foote 2017-04-26 19:50:16 UTC
The \t as a replacement seems does work. Except...

It seems like using the very common "^$" regex match of an empty paragraph puts the search into a mode where the \t does not get parsed.

That makes Finding an empty string paragraph as target, and replacing with a string containing a \t <Tab> rather hard.
Comment 4 V Stuart Foote 2017-04-26 19:59:20 UTC
*** Bug 107429 has been marked as a duplicate of this bug. ***
Comment 5 Justin L 2018-02-07 19:21:03 UTC
This will require some kind of hacky programming to fix.  "$" and "^$" are definitely edge cases.
-sw/source/core/crsr/findtxt.cxx:DoSearch() - if it fails, then checks for three special searches
const bool bChkEmptyPara = bRegSearch && 2 == rSearchOpt.searchString.getLength() && ( rSearchOpt.searchString == "^$" || rSearchOpt.searchString == "$^" );
const bool bChkParaEnd = bRegSearch && rSearchOpt.searchString == "$";

proposed hack:  https://gerrit.libreoffice.org/49387
Comment 6 Commit Notification 2018-02-13 15:49:57 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9bb369edf5471d0b29b5cea86d7203831f93d529

tdf#102374: regex allow ReplaceBackReferences for $ search

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2018-02-14 09:41:27 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5054456a6ed8ef7cd2a05fb09e1954eb02eaf0f7&h=libreoffice-6-0

tdf#102374: regex allow ReplaceBackReferences for $ search

It will be available in 6.0.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 V Stuart Foote 2018-02-16 23:58:52 UTC
*** Bug 91033 has been marked as a duplicate of this bug. ***
Comment 9 V Stuart Foote 2018-02-17 00:02:02 UTC
*** Bug 112575 has been marked as a duplicate of this bug. ***