MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / MatchRegexAnywhere

Function MatchRegexAnywhere

tests/gtest/gtest-all.cc:10650–10662  ·  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

10648// exponential with respect to the regex length + the string length,
10649// but usually it's must faster (often close to linear).
10650bool MatchRegexAnywhere(const char* regex, const char* str) {
10651 if (regex == nullptr || str == nullptr) return false;
10652
10653 if (*regex == '^')
10654 return MatchRegexAtHead(regex + 1, str);
10655
10656 // A successful match can be anywhere in str.
10657 do {
10658 if (MatchRegexAtHead(regex, str))
10659 return true;
10660 } while (*str++ != '\0');
10661 return false;
10662}
10663
10664// Implements the RE class.
10665

Callers 2

FullMatchMethod · 0.85
PartialMatchMethod · 0.85

Calls 1

MatchRegexAtHeadFunction · 0.85

Tested by

no test coverage detected