[ 
https://issues.apache.org/jira/browse/METRON-1431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16342625#comment-16342625
 ] 

ASF GitHub Bot commented on METRON-1431:
----------------------------------------

Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/912#discussion_r164303393
  
    --- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/RegExFunctions.java
 ---
    @@ -100,4 +100,39 @@ public Object apply(List<Object> list) {
           return matcher.group(groupNumber);
         }
       }
    +
    +  @Stellar(name = "REGEXP_REPLACE",
    +      description = "Replace all occurences of the regex pattern within 
the string by value",
    +      params = {
    +          "string - The input string",
    +          "pattern - The regex pattern to be replaced. Special characters 
must be escaped (e.g. \\\\d)",
    +          "value - The value to replace the regex pattern"
    +      },
    +      returns = "The modified input string with replaced values")
    +  public static class RegexpReplace extends BaseStellarFunction {
    +
    +    @Override
    +    public Object apply(List<Object> list) {
    +      if (list.size() != 3) {
    +        throw new IllegalStateException(
    +            "REGEXP_REPLACE expects three args: [string, pattern, value]"
    +                + " where pattern is a regexp pattern");
    +      }
    +      String str = (String) list.get(0);
    +      String stringPattern = (String) list.get(1);
    +      String value = (String) list.get(2);
    +
    --- End diff --
    
    I think you want to check for null or empty
    
    StringUtils.isEmpty(str)


> Add REGEXP_REPLACE function to Stellar
> --------------------------------------
>
>                 Key: METRON-1431
>                 URL: https://issues.apache.org/jira/browse/METRON-1431
>             Project: Metron
>          Issue Type: Improvement
>            Reporter: 1havran
>            Priority: Minor
>
> Add REGEXP_REPLACE(input, pattern, value) function to Stellar that will 
> replaceĀ all occurrences of regex pattern within the input by provided value.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to