MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / MatchRegexAnywhere

Function MatchRegexAnywhere

test/common/gtest/gtest.cpp:9424–9437  ·  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

9422// exponential with respect to the regex length + the string length,
9423// but usually it's must faster (often close to linear).
9424bool MatchRegexAnywhere(const char* regex, const char* str) {
9425 if (regex == NULL || str == NULL)
9426 return false;
9427
9428 if (*regex == '^')
9429 return MatchRegexAtHead(regex + 1, str);
9430
9431 // A successful match can be anywhere in str.
9432 do {
9433 if (MatchRegexAtHead(regex, str))
9434 return true;
9435 } while (*str++ != '\0');
9436 return false;
9437}
9438
9439// Implements the RE class.
9440

Callers 2

FullMatchMethod · 0.85
PartialMatchMethod · 0.85

Calls 1

MatchRegexAtHeadFunction · 0.85

Tested by

no test coverage detected