| 39 | } // namespace |
| 40 | |
| 41 | FindRegexMatch::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 | |
| 60 | std::shared_ptr<RegexMatch> Regex::findAll(const std::string& expression) const { |
| 61 | return std::make_shared<FindAllRegexMatch>(regexImpl, expression); |
nothing calls this directly
no test coverage detected