linrrzqqq commented on code in PR #66050:
URL: https://github.com/apache/doris/pull/66050#discussion_r3680010042


##########
be/src/exprs/function/function_regexp.cpp:
##########
@@ -159,9 +163,9 @@ 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() && 
!matches[index].empty()) {

Review Comment:
   should not judge `matches[idx].empty()` anymore:
   ```sql
   spark-sql (default)> select regexp_extract_all('a b', '(a)|(b)', 2);
   ["","b"]
   ```



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