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

ASF GitHub Bot commented on NIFI-5826:
--------------------------------------

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

    https://github.com/apache/nifi/pull/3183#discussion_r236789857
  
    --- Diff: 
nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/util/RecordPathUtils.java
 ---
    @@ -39,4 +39,44 @@ public static String getFirstStringValue(final 
RecordPathSegment segment, final
     
             return stringValue;
         }
    +
    +    public static String unescapeBackslash(String value) {
    +        if (value == null || value.isEmpty()) {
    +            return value;
    +        }
    +        // need to escape characters after backslashes
    +        final StringBuilder sb = new StringBuilder();
    +        boolean lastCharIsBackslash = false;
    +        for (int i = 0; i < value.length(); i++) {
    +            final char c = value.charAt(i);
    +
    --- End diff --
    
    Added to the PR description:
    EL References: StringLiteralEvaluator. Special characters (backslash 
sequences) will be handled for any string literal value, and will affect the 
way regex and escaped chars must be defined. Same logic has been added to 
RecordPathUtils.unescapeBackslash.


> UpdateRecord processor throwing PatternSyntaxException
> ------------------------------------------------------
>
>                 Key: NIFI-5826
>                 URL: https://issues.apache.org/jira/browse/NIFI-5826
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.5.0
>         Environment: Nifi in docker container
>            Reporter: ravi kargam
>            Assignee: Ed Berezitsky
>            Priority: Minor
>         Attachments: UpdateRecord_Config_Exception.JPG
>
>
> with replacement value strategy as Record Path Value,
> I am trying to replace square bracket symbol *[* with parenthesis symbol *(* 
> in my employeeName column in my csvReader structure with below syntax
> replaceRegex(/employeeName, "[\[]", "(")
> Processor is throwing following exception.
> RecordPathException: java.util.regex.PatternSyntaxException: Unclosed 
> character class near index 4 [\\[]
> It worked fine with other special characters such as \{, }, <, >, ;, _, "
> For double qoute ("), i had to use single escape character, for above listed 
> other characters, worked fine without any escape character. Other folks in 
> Nifi Slack tried \s, \d, \w, \. 
> looks like non of them worked.
> replace function worked for replacing [ and ]characters. didn't test any 
> other characters.
> Please address resolve the issue.
> Regards,
> Ravi
>  
>  
>  



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

Reply via email to