Anthrino commented on code in PR #3408:
URL: https://github.com/apache/calcite/pull/3408#discussion_r1317637600


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -488,13 +502,74 @@ public List<String> regexpExtractAll(String value, String 
regex) {
       ImmutableList.Builder<String> matches = ImmutableList.builder();
       while (matcher.find()) {
         String match = matcher.group(matcher.groupCount());
-        if (match != null && !match.isEmpty()) {
+        if (match != null) {
           matches.add(match);
         }
       }
       return matches.build();
     }
 
+    /** SQL {@code REGEXP_INSTR(value, regexp)} function.
+     *  Returns 0 if there is no match or regex is empty. Returns an exception 
if regex is invalid.
+     *  Uses position=1, occurrence=1, occurrencePosition=0 as default values 
if not specified. */
+    public Integer regexpInstr(String value, String regex) {
+      return regexpInstr(value, regex, 1, 1, 0);
+    }
+
+    /** SQL {@code REGEXP_INSTR(value, regexp, position)} function.
+     *  Returns 0 if there is no match, regex is empty, or if position is 
beyond range.
+     *  Returns an exception if regex or position is invalid.
+     *  Uses occurrence=1, occurrencePosition=0 as default value when not 
specified. */
+    public Integer regexpInstr(String value, String regex, int position) {
+      return regexpInstr(value, regex, position, 1, 0);
+    }
+
+    /** SQL {@code REGEXP_INSTR(value, regexp, position, occurrence)} function.
+     *  Returns NULL if there is no match, regex is empty, or if position or 
occurrence

Review Comment:
   My bad missed on correcting this instance, should be aligned with the others 
thanks for catching it!



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

Reply via email to