siddharthteotia commented on code in PR #9123:
URL: https://github.com/apache/pinot/pull/9123#discussion_r935881001


##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java:
##########
@@ -560,4 +560,116 @@ public static String decodeUrl(String input)
       throws UnsupportedEncodingException {
     return URLDecoder.decode(input, StandardCharsets.UTF_8.toString());
   }
+
+  /**
+   * Replace a regular expression pattern. If matchStr is not found, inputStr 
will be returned. By default, all
+   * occurences of match pattern in the input string will be replaced. Default 
matching pattern is case sensitive.
+   *
+   * @param inputStr Input string to apply the regexpReplace
+   * @param matchStr Regexp or string to match against inputStr
+   * @param replaceStr Regexp or string to replace if matchStr is found
+   * @param startPos Index of inputStr from where matching should start. 
Default is 0.
+   * @param occurence Controls which occurence of the matched pattern must be 
replaced. Counting starts at 0. Default
+   *                  is -1
+   * @param flag Single character flag that controls how the regex finds 
matches in inputStr. If an incorrect flag is
+   *            specified, the function applies default case sensitive match. 
Only one flag can be specified. Supported
+   *             flags:
+   *             i -> Case insensitive
+   *             m -> Treats the string to match as multiple lines
+   *             x -> Add comments to the regular expression
+   * @return replaced input string
+   */
+  @ScalarFunction
+  public static String regexpReplace(String inputStr, String matchStr, String 
replaceStr, int startPos,
+      int occurence, String flag) {
+    Integer patternFlag;
+    switch (flag) {
+      case "i":
+        patternFlag = Pattern.CASE_INSENSITIVE;
+        break;
+      case "m":
+        patternFlag = Pattern.MULTILINE;
+        break;
+      case "x":
+        patternFlag = Pattern.COMMENTS;

Review Comment:
   Suggest not handling m and x now. We can add them later and keep it simple 
for now



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to