From 014f3b98736bb3a777721ae39f1a52eb662fd932 Mon Sep 17 00:00:00 2001 From: Mehmet Murat Akburak Date: Tue, 16 Jun 2020 11:04:14 +0300 Subject: [PATCH] [PowerRename] capturing groups fix (#4181) * Fix capturing group bug when Match All Occurrences is not checked * Capture groups are now available when Match All Occurences option is not selected * Bug fix when capture group is indicated with leading zeros. $01 should be considered as $1 etc * Use flags in regex_replace() when Match All Occurences is not selected Now the behaviour is consistent with how regex works when Match All Occurences is selected. --- src/modules/powerrename/lib/PowerRenameRegEx.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/modules/powerrename/lib/PowerRenameRegEx.cpp b/src/modules/powerrename/lib/PowerRenameRegEx.cpp index 3b7b3dee15..d0944ed1ac 100644 --- a/src/modules/powerrename/lib/PowerRenameRegEx.cpp +++ b/src/modules/powerrename/lib/PowerRenameRegEx.cpp @@ -210,11 +210,7 @@ HRESULT CPowerRenameRegEx::Replace(_In_ PCWSTR source, _Outptr_ PWSTR* result) } else { - std::wsmatch m; - if (std::regex_search(sourceToUse, m, pattern)) - { - res = sourceToUse.replace(m.prefix().length(), m.length(), replaceTerm); - } + res = regex_replace(wstring(source), pattern, replaceTerm, regex_constants::format_first_only); } } else