MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / MatchRegexAnywhere

Function MatchRegexAnywhere

rtpose_wrapper/src/gtest/gtest-all.cpp:8159–8172  ·  view source on GitHub ↗

Returns true iff regex matches any substring of str. regex must be a valid simple regular expression, or the result is undefined. The algorithm is recursive, but the recursion depth doesn't exceed the regex length, so we won't need to worry about running out of stack space normally. In rare cases the time complexity can be exponential with respect to the regex length + the string length, but us

Source from the content-addressed store, hash-verified

8157// exponential with respect to the regex length + the string length,
8158// but usually it's must faster (often close to linear).
8159bool MatchRegexAnywhere(const char* regex, const char* str) {
8160 if (regex == NULL || str == NULL)
8161 return false;
8162
8163 if (*regex == '^')
8164 return MatchRegexAtHead(regex + 1, str);
8165
8166 // A successful match can be anywhere in str.
8167 do {
8168 if (MatchRegexAtHead(regex, str))
8169 return true;
8170 } while (*str++ != '\0');
8171 return false;
8172}
8173
8174// Implements the RE class.
8175

Callers 2

FullMatchMethod · 0.85
PartialMatchMethod · 0.85

Calls 1

MatchRegexAtHeadFunction · 0.85

Tested by

no test coverage detected