MCPcopy Create free account
hub / github.com/apache/arrow / RegexMatch

Function RegexMatch

cpp/src/arrow/util/regex.h:32–48  ·  view source on GitHub ↗

Match regex against target and produce string_views out of matches.

Source from the content-addressed store, hash-verified

30
31/// Match regex against target and produce string_views out of matches.
32inline bool RegexMatch(const std::regex& regex, std::string_view target,
33 std::initializer_list<std::string_view*> out_matches) {
34 assert(regex.mark_count() == out_matches.size());
35
36 std::match_results<decltype(target.begin())> match;
37 if (!std::regex_match(target.begin(), target.end(), match, regex)) {
38 return false;
39 }
40
41 // Match #0 is the whole matched sequence
42 assert(regex.mark_count() + 1 == match.size());
43 auto out_it = out_matches.begin();
44 for (size_t i = 1; i < match.size(); ++i) {
45 **out_it++ = target.substr(match.position(i), match.length(i));
46 }
47 return true;
48}
49
50} // namespace internal
51} // namespace arrow

Callers 2

MatchFixedOffsetFunction · 0.85
TESTFunction · 0.85

Calls 6

substrMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
positionMethod · 0.45
lengthMethod · 0.45

Tested by 1

TESTFunction · 0.68