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


##########
be/src/exprs/function/function_regexp.cpp:
##########
@@ -178,10 +178,13 @@ struct RegexpExtractEngine {
                     results.emplace_back(matches[1].str());
                 }
                 if (matches[0].length() == 0) {
-                    if (search_start == search_end) {
+                    // A zero-width match (e.g. a lookahead) may sit anywhere 
after
+                    // `search_start`, so step past the matched position 
rather than
+                    // the old start, otherwise the same position is matched 
again.
+                    if (matches[0].second == search_end) {
                         break;
                     }
-                    search_start += 1;
+                    search_start = matches[0].second + 1;

Review Comment:
   Moving the range start here resets Boost's match context, not just its scan 
position. It drops the second capture for `regexp_extract_all('aa', 
'(?<=(a))')` because the search at offset 2 cannot inspect the preceding `a`; 
it skips Boost's required same-position consuming retry, so 
`regexp_extract_all('xa', '((?<=x)|a)')` becomes `['']` instead of `['','a']`; 
and it can invent anchored matches—for `xxa?b` with `(?<=a)|^(b)`, restarting 
at `b` lets `^` capture in the middle of the original input. The array form 
shares this loop. Please retain the original range and Boost's zero-length 
progression (for example, use `boost::cregex_iterator`) and cover these 
assertion/anchor cases in both result forms.



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