Bug 168226

Summary: KReplace: Placeholder substitution for regular expressions not implemented
Product: [Frameworks and Libraries] kdelibs Reporter: Christoph Burgmer <chrislb>
Component: kdeuiAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: edgaribsen2, peterp, Wolfram.R.Sieber
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Test case

Description Christoph Burgmer 2008-08-03 17:00:08 UTC
Version:            (using KDE 4.1.0)
Installed from:    Debian testing/unstable Packages

KReplaceDialog [1] allows for replacing text matched by a regular expressions with substituting content from the match using placeholders (\0, \1...). This can be set by giving option BackReference = 512.

KFindDialog implements widgets for setting this option in [2].

KReplace only implements placeholder \0 though, which means only substituting the whole match.

Currently extracting a partial match from the given regular expression is not supported.

I consider this a bug as this functionality is clearly wanted by the UI but not given by the underlying library. This feature is used in the KTextEdit widget.

See the Kate implementation on replacing using placeholders [4]. Maybe this can be merged into KReplace.

[1] http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKReplaceDialog.html
[2] http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/kfinddialog_8cpp-source.html#l00116
[3] http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/kreplace_8cpp-source.html#l00250
[4] http://api.kde.org/4.x-api/kdelibs-apidocs/kate/html/katesearchbar_8cpp-source.html#l00338
Comment 1 Christoph Burgmer 2008-08-03 17:05:22 UTC
Created attachment 26601 [details]
Test case

See Bug 140837.

See attachment for a testcase. This is a PyKDE application that uses a
KTextEdit. For any string input a substring string "test" will be substituted
with itself and the whole input will be printed to stdout. "Test that" will
currently resolve to "\1 that" which shows that \1 is not substituted.
Comment 2 Christoph Feck 2010-01-05 20:10:08 UTC
*** Bug 137374 has been marked as a duplicate of this bug. ***
Comment 3 David Faure 2010-05-19 00:22:25 UTC
*** Bug 227215 has been marked as a duplicate of this bug. ***
Comment 4 David Faure 2010-05-19 00:28:43 UTC
SVN commit 1128317 by dfaure:

Finally implement support for other back references than \0 in the find/replace dialog.
BUGS: 168226 125443
CCBUG: 201057


 M  +25 -16    findreplace/kreplace.cpp  
 M  +19 -4     tests/kreplacetest.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1128317
Comment 5 David Faure 2010-05-19 01:17:05 UTC
*** Bug 158397 has been marked as a duplicate of this bug. ***
Comment 6 FiNeX 2010-09-05 21:26:02 UTC
*** Bug 140837 has been marked as a duplicate of this bug. ***