Version: 3.3.2 (using KDE KDE 3.5.2) Installed from: Fedora RPMs Compiler: gcc 4.1.0 Fedora Core 5 / P4 1.7 GHz platform OS: Linux When performing regular-expression find-and-replace, the \2 placeholder to indicate substitution by the second match is not substituted and simply appears as \2. Example: I want to change variable names xmin_tex_plane, xmax_tmx_plane, ymax_tmy_plane, zmin_tmz_plane so that each begins with m_ (eg: m_xmin_tex_plane). To do this, I perform the following sequence of steps: 1. Ctrl-R to activate regular expression find-and-replace 2. declare the regular expression to be : ([xyz])(min|max)(_t[em][eyz]) 3. I enable the check-box labelled "Regular expression" 4. I declare the replace string to be : m_\1\2\3 5. I enable the "Use placeholders" check box The result is that the above variables are modified to m_x\2_tex_plane, m_x\2_tmx_plane, m_y\2_tmy_plane, m_z\2_tmz_plane.
The above bug doesn't show up if there is a piece of text separating the \1 and \2 match strings. For example, if I change the regular expression to be ([xyz])m(in|ax)(_t[em][xyz]) then using the same replace string m_\1\2\3 yields perfect results.
Must be Kate's. Reassigning.
Even simpler case -- without regexps at all. Let's say we have text vector a; vector b; Now, replace vector with std::\0 with placeholders enabled. The result? std::\0 a; std::\0 b;
Comment #3 is confusing. To me the behaviour is correct. Placeholders without reg exps are not useful afaik.
I'll try and look into that
Dominik, it is totally useful. Full match works only and this make sense. Try to replace oh, really long phrase I don't know how long it is with "oh, really long phrase I don't know how long it is" And repeat it ten times with various phrases. How it would be much easier with oh, really long phrase I don't know how long it is replace "\0"
SVN commit 628855 by dhaumann: Patch by Anders: fix bug in search&replace; placeholder did not work correctly CCBUG: 134101 M +1 -1 katesearch.cpp --- branches/KDE/3.5/kdelibs/kate/part/katesearch.cpp #628854:628855 @@ -393,7 +393,7 @@ kdDebug()<<"KateSearch::replaceOne(): you don't have "<<ccap<<" backreferences in regexp '"<<m_re.pattern()<<"'"<<endl; } } - pos = br.search( replaceWith, pos+kMax(br.matchedLength(), (int)sc.length()) ); + pos = br.search( replaceWith, pos + (int)sc.length() ); } }
Maciej: In the meantime I understood your issue ;) It's simply that \0 is the "whole match", which is if regexp is disabled of course the text in the line-edit itself. Can you open another bug report about it, please? I think it's a valid bug (especially because the user interface does not disable the placeholder button when regexp is disabled)
SVN commit 628866 by alund: get the right position when inserting backreferences BUG: 134101 M +1 -1 katesearch.cpp --- trunk/KDE/kdelibs/kate/part/katesearch.cpp #628865:628866 @@ -384,7 +384,7 @@ kDebug()<<"KateSearch::replaceOne(): you don't have "<<ccap<<" backreferences in regexp '"<<m_re.pattern()<<"'"<<endl; } } - pos = br.indexIn( replaceWith, pos + qMax(br.matchedLength(), (int)sc.length()) ); + pos = br.indexIn( replaceWith, pos + (int)sc.length()); } }
Wrt the 'use placeholders' button being enabled during non-regex replace, that is a bug in the KDE find/replace dialog, which is not owned by Kate. For Kate in KDE4 this will not be an issue -- we will not be using that dialog anymore, as we are switching to embed the tool dialogs in the view. I hope that this includes the replace dialog.
Dominik: done, https://bugs.kde.org/show_bug.cgi?id=140970 Anders, > Wrt the 'use placeholders' button being enabled during non-regex replace, > that is a bug Why it is a bug? It says "use the entire text in replace editbox".
Also, (another bug, but I am currently too lazy to submit it): If you edit the regex with KRegexp (or whatever it is called) and add brackets ('(' and ')'), when you click OK they are changed to square brackets ('[' and ']'). Weird.
On Wednesday 31 January 2007, Tim Hutt wrote: > Also, (another bug, but I am currently too lazy to submit it): > > If you edit the regex with KRegexp (or whatever it is called) and add > brackets ('(' and ')'), when you click OK they are changed to square > brackets ('[' and ']'). Weird. Well, this is not a bug in kate, rather in the kde find dialog or in kreplace, which i'd think returned a string. So it would be a nice touch to report it separately if you please ;)
On Wednesday 31 January 2007, Maciej Pilichowski wrote: > Why it is a bug? It says "use the entire text in replace editbox". Because it's not meant to be acitvated during non-regex replace. That said, I can see the use for it.
On Wednesday 31 January 2007, Maciej Pilichowski wrote: > Try to replace > oh, really long phrase I don't know how long it is > with > "oh, really long phrase I don't know how long it is" > > And repeat it ten times with various phrases. How it would be much easier > with oh, really long phrase I don't know how long it is > replace > "\0" This is an example of why regex replace rocks, you can do all those operations at once with regex replace ;)
> This is an example of why regex replace rocks, Better is the enemy of good. How can you replace (easily) a bit longer phrase? Like this one. A *lot* of work! Using regexp of course.