File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed
Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,6 @@ export import std;
7575#include < iostream>
7676#include < memory>
7777#include < optional>
78- #include < regex>
7978#include < sstream>
8079#include < stack>
8180#include < string_view>
@@ -231,6 +230,18 @@ template <class T = std::string_view, class TDelim>
231230 }
232231 return output;
233232}
233+ constexpr auto regex_match (const char *str, const char *pattern) -> bool {
234+ if (*pattern == ' \0 ' && *str == ' \0 ' ) return true ;
235+ if (*pattern == ' \0 ' && *str != ' \0 ' ) return false ;
236+ if (*str == ' \0 ' && *pattern != ' \0 ' ) return false ;
237+ if (*pattern == ' .' ) {
238+ return regex_match (str+1 , pattern+1 );
239+ }
240+ if (*pattern == *str) {
241+ return regex_match (str+1 , pattern+1 );
242+ }
243+ return false ;
244+ }
234245} // namespace utility
235246
236247namespace reflection {
@@ -2031,10 +2042,10 @@ class runner {
20312042 }
20322043
20332044 if (!detail::cfg::query_pattern.empty ()) {
2034- const static std::regex regex ( detail::cfg::query_regex_pattern) ;
2035- bool matches = std ::regex_match (test.name .data (), regex);
2045+ const static auto regex = detail::cfg::query_regex_pattern;
2046+ bool matches = utility ::regex_match (test.name .data (), regex. c_str () );
20362047 for (const auto & tag2 : test.tag ) {
2037- matches |= std ::regex_match (tag2.data (), regex);
2048+ matches |= utility ::regex_match (tag2.data (), regex. c_str () );
20382049 }
20392050 if (matches) {
20402051 execute = !detail::cfg::invert_query_pattern;
Original file line number Diff line number Diff line change @@ -435,7 +435,21 @@ int main() {
435435 static_assert (" fake_cfg" == reflection::type_name<fake_cfg>());
436436#endif
437437 }
438-
438+
439+ {
440+ static_assert (utility::regex_match (" " , " " ));
441+ static_assert (utility::regex_match (" hello" , " hello" ));
442+ static_assert (utility::regex_match (" hello" , " h.llo" ));
443+ static_assert (utility::regex_match (" hello" , " he..o" ));
444+ static_assert (not utility::regex_match (" hello" , " hella" ));
445+ static_assert (not utility::regex_match (" hello" , " helao" ));
446+ static_assert (not utility::regex_match (" hello" , " hlllo" ));
447+ static_assert (not utility::regex_match (" hello" , " " ));
448+ static_assert (not utility::regex_match (" " , " hello" ));
449+ static_assert (not utility::regex_match (" hi" , " hello" ));
450+ static_assert (not utility::regex_match (" hello there" , " hello" ));
451+ }
452+
439453 {
440454 test_assert (utility::is_match (" " , " " ));
441455 test_assert (utility::is_match (" " , " *" ));
You can’t perform that action at this time.
0 commit comments