mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[PowerRename] Clear capturing groups with more than 1 digit (#5116)
User has actually signed CLA, see #4722 * Clear capturing groups with more than 1 digit * Fix issue in regex pattern * Add unittest * Fix regex patterns * Edit unittest * Fix regex pattern, add some tests
This commit is contained in:
committed by
GitHub
parent
3acc96cab1
commit
35a214603f
@@ -201,6 +201,9 @@ HRESULT CPowerRenameRegEx::Replace(_In_ PCWSTR source, _Outptr_ PWSTR* result)
|
||||
std::wstring searchTerm(m_searchTerm);
|
||||
std::wstring replaceTerm(m_replaceTerm ? wstring(m_replaceTerm) : wstring(L""));
|
||||
|
||||
replaceTerm = regex_replace(replaceTerm, std::wregex(L"(([^\\$]|^)(\\$\\$)*)\\$[0]"), L"$1$$$0");
|
||||
replaceTerm = regex_replace(replaceTerm, std::wregex(L"(([^\\$]|^)(\\$\\$)*)\\$([1-9])"), L"$1$0$4");
|
||||
|
||||
if (m_flags & UseRegularExpressions)
|
||||
{
|
||||
std::wregex pattern(m_searchTerm, (!(m_flags & CaseSensitive)) ? regex_constants::icase | regex_constants::ECMAScript : regex_constants::ECMAScript);
|
||||
|
||||
Reference in New Issue
Block a user