github-actions[bot] commented on code in PR #66050:
URL: https://github.com/apache/doris/pull/66050#discussion_r3701296392


##########
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:
   The RE2 side and the simple `^` case are fixed, but the Boost loop still 
restarts buffer-anchor semantics after the first match. The advanced call uses 
`match_prev_avail | match_not_bol`; Boost documents that `match_prev_avail` 
makes `match_not_bol` ignored, defines `match_not_bob` for `\A`, and uses 
`match_prev_avail | match_not_bob` in its repeated-`regex_search` example.
   
   With `enable_extended_regex=true`, `regexp_extract_all_array('ab', 
'a|(?<=a)\\Ab', 0)` can therefore treat the suffix at `b` as a new buffer and 
return `["a","b"]` instead of `["a"]`. Please preserve beginning-of-buffer 
semantics for the advanced search and add a Boost-path regression. This is a 
follow-up to the same original-subject issue rather than a new thread.
   



-- 
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]

Reply via email to