mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Tweak EscapeRegExp()
This commit is contained in:
parent
c31ecbfc83
commit
61cbb81756
@ -379,33 +379,17 @@ bool ConfigParser::GetSectionVariable(std::wstring& strVariable, std::wstring& s
|
||||
}
|
||||
|
||||
/*
|
||||
** Used to escape regular expression metacharacters for use in IfMatch
|
||||
** Escapes reserved PCRE regex metacharacters.
|
||||
**
|
||||
*/
|
||||
void ConfigParser::EscapeRegExp(std::wstring& str)
|
||||
{
|
||||
auto replace = [&str](WCHAR reservedChar)
|
||||
{
|
||||
size_t start = 0;
|
||||
while ((start = str.find(reservedChar, start)) != std::wstring::npos)
|
||||
while ((start = str.find_first_of(L"\\^$|()[{.+*?", start)) != std::wstring::npos)
|
||||
{
|
||||
str.insert(start, L"\\");
|
||||
start += 2;
|
||||
}
|
||||
};
|
||||
|
||||
replace(L'\\');
|
||||
replace(L'^');
|
||||
replace(L'$');
|
||||
replace(L'|');
|
||||
replace(L'(');
|
||||
replace(L')');
|
||||
replace(L'[');
|
||||
replace(L'{');
|
||||
replace(L'.');
|
||||
replace(L'+');
|
||||
replace(L'*');
|
||||
replace(L'?');
|
||||
}
|
||||
|
||||
void ConfigParser::ResetMonitorVariables(MeterWindow* meterWindow)
|
||||
|
Loading…
Reference in New Issue
Block a user