File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#pragma once
22
3+ #include < optional>
4+ #include < regex>
35#include < string>
46#include < string_view>
57
@@ -11,6 +13,6 @@ MAA_NS_BEGIN
1113MAA_UTILS_API std::wstring to_u16 (std::string_view u8str);
1214MAA_UTILS_API std::string from_u16 (std::wstring_view u16str);
1315
14- MAA_UTILS_API bool regex_valid (const std::wstring& regex);
16+ MAA_UTILS_API std::optional<std::wregex> regex_valid (const std::wstring& regex);
1517
1618MAA_NS_END
Original file line number Diff line number Diff line change @@ -141,16 +141,15 @@ std::string from_u16(std::wstring_view u16str)
141141 return output;
142142}
143143
144- bool regex_valid (const std::wstring& regex)
144+ std::optional<std::wregex> regex_valid (const std::wstring& regex)
145145{
146146 try {
147- std::wregex _ (regex);
147+ return std::wregex (regex);
148148 }
149149 catch (const std::regex_error& e) {
150150 LogError << e.what () << VAR (regex);
151- return false ;
151+ return std:: nullopt ;
152152 }
153- return true ;
154153}
155154
156155MAA_NS_END
You can’t perform that action at this time.
0 commit comments