ccl125 commented on code in PR #66050:
URL: https://github.com/apache/doris/pull/66050#discussion_r3703212214
##########
be/src/exprs/function/function_regexp.cpp:
##########
@@ -159,29 +165,35 @@ struct RegexpExtractEngine {
pos += 1;
continue;
}
- // Extract first capturing group
- if (matches.size() > 1 && !matches[1].empty()) {
- results.emplace_back(matches[1].data(), matches[1].size());
+ // Extract the capturing group with the given index
+ if (static_cast<size_t>(index) < matches.size()) {
+ const re2::StringPiece& group = matches[index];
+ if (group.data() != nullptr) {
+ results.emplace_back(group.data(), group.size());
+ } else {
+ results.emplace_back();
+ }
}
- // Move position forward
- auto offset = std::string(str_pos, str_size)
- .find(std::string(matches[0].data(),
matches[0].size()));
- pos += offset + matches[0].size();
+ // Move position forward. matches[0] points into the searched
string,
+ // so its address gives the exact match offset — no textual
find needed.
+ pos += (matches[0].data() - str_pos) + matches[0].size();
Review Comment:
Fixed in 4737a9d — switched the boost flags to the documented
repeated-search idiom `match_prev_avail | match_not_bob` (with match_prev_avail
set, match_not_bol is ignored; match_not_bob keeps `\A` anchored to the start
of the original buffer).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]