ccl125 commented on code in PR #66050:
URL: https://github.com/apache/doris/pull/66050#discussion_r3687664774
##########
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 cf47ba1 — the re2 loop now calls `Match` on the original subject
with an advancing start position (so `^` and left context refer to the original
string), and the boost loop keeps the original begin reachable with
`match_prev_avail` and suppresses bol at the advanced origin with
`match_not_bol`. Added `('aa', '^a', 0) -> ['a']` as a regression case.
--
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]