You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just encountered a strange regex behavior when using \K and replacing with a matching group. Let's say we have this string aaa bbb ccc and we use the pattern aaa\K bbb (ccc) and replace with \1, the expected behavior would be to replace bbb ccc with ccc returning aaaccc; that actually works as expected. Now let's try the same pattern when multiple matches are expected (i.e., input string = aaa bbb ccc aaa bbb ccc), in that case, the replacing has no effect whatsoever (my guess is that it replaces with the full match instead of the provided group).
Steps to Reproduce the Issue
In a new/empty file, add the following text:
aaa bbb ccc aaa bbb ccc
Open the "find & replace" dialog and set the search mode to "Regular expression".
Type aaa\K bbb (ccc) in the "Find" field and \1 in the "Replace field".
Click "Replace" (not "Replace all").
Expected Behavior
Each aaa bbb ccc string should be replaced with aaaccc.
Actual Behavior
Nothing is replaced and the matches stay the same. Note: as mentioned above, there has to be more than one match in order to reproduce the issue.
Debug Information
Notepad++ v7.6.3 (32-bit)
Build time : Jan 27 2019 - 17:20:30
Path : C:\Program Files (x86)\Notepad++\notepad++.exe
Admin mode : ON
Local Conf mode : OFF
OS : Windows 7 (64-bit)
Plugins : DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll
Screenshot:
The text was updated successfully, but these errors were encountered:
This will be of course NOT what you want to hear, but it is VERY-long-known that \K in a regex in Notepad++ does not work correctly (in most cases) unless you use "Replace All". Can it be fixed? Sure, pretty much all software problems can be fixed. The bigger question is Will it ever be fixed?
Description of the Issue
I just encountered a strange regex behavior when using
\K
and replacing with a matching group. Let's say we have this stringaaa bbb ccc
and we use the patternaaa\K bbb (ccc)
and replace with\1
, the expected behavior would be to replacebbb ccc
withccc
returningaaaccc
; that actually works as expected. Now let's try the same pattern when multiple matches are expected (i.e., input string =aaa bbb ccc aaa bbb ccc
), in that case, the replacing has no effect whatsoever (my guess is that it replaces with the full match instead of the provided group).Steps to Reproduce the Issue
aaa\K bbb (ccc)
in the "Find" field and\1
in the "Replace field".Expected Behavior
Each
aaa bbb ccc
string should be replaced withaaaccc
.Actual Behavior
Nothing is replaced and the matches stay the same. Note: as mentioned above, there has to be more than one match in order to reproduce the issue.
Debug Information
Notepad++ v7.6.3 (32-bit)
Build time : Jan 27 2019 - 17:20:30
Path : C:\Program Files (x86)\Notepad++\notepad++.exe
Admin mode : ON
Local Conf mode : OFF
OS : Windows 7 (64-bit)
Plugins : DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll
Screenshot:
The text was updated successfully, but these errors were encountered: