MCPcopy Create free account
hub / github.com/cucumber/cucumber-cpp / FindRegexMatch

Method FindRegexMatch

src/Regex.cpp:41–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39} // namespace
40
41FindRegexMatch::FindRegexMatch(const std::regex& regexImpl, const std::string& expression) {
42 std::smatch matchResults;
43 regexMatched = std::regex_search(expression, matchResults, regexImpl);
44 if (regexMatched) {
45 std::smatch::const_iterator i = matchResults.begin();
46 if (i != matchResults.end())
47 // Skip capture group 0 which is the whole match, not a user marked sub-expression
48 ++i;
49 for (; i != matchResults.end(); ++i) {
50 if (i->matched) {
51 RegexSubmatch s = {*i, utf8CodepointOffset(expression, i->first)};
52 submatches.push_back(s);
53 } else {
54 submatches.push_back(RegexSubmatch());
55 }
56 }
57 }
58}
59
60std::shared_ptr<RegexMatch> Regex::findAll(const std::string& expression) const {
61 return std::make_shared<FindAllRegexMatch>(regexImpl, expression);

Callers

nothing calls this directly

Calls 2

utf8CodepointOffsetFunction · 0.85
RegexSubmatchClass · 0.85

Tested by

no test coverage detected