mrhhsg commented on code in PR #68358:
URL: https://github.com/apache/doris/pull/68358#discussion_r4078743569
##########
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:
Confirmed all three cases against Boost directly (old loop / previous
revision / `cregex_iterator`):
- `'aa'` / `(?<=(a))`: `['a','a']` / `['a']` / `['a','a']`
- `'xa'` / `((?<=x)|a)`: `['','a']` / `['']` / `['','a']`
- `'xxa?b'` / `(?<=a)|^(b)`: `[]` / `['b']` / `[]`
Switched the Boost branch to `boost::cregex_iterator` over the whole input,
so the preceding text stays visible and Boost's own zero-length progression
(same-position consuming retry, then advance) is used. The Jira-style lookahead
cases and the existing extended-regex regression outputs are unchanged. Added
the three cases above to both the BE UT and the regression suite for
`regexp_extract_all` and `regexp_extract_all_array`.
--
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]