Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

NiFi UpdateRecord processor is throwing PatternSyntaxException: Unclosed character class near index 4

Solved Go to solution
Highlighted

NiFi UpdateRecord processor is throwing PatternSyntaxException: Unclosed character class near index 4

New Contributor

updaterecord-config-exception.jpgI 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 [\\[]

same regular expression compiled successfully using java method java.util.regex.Pattern.compile method.

replaceRegex is working fine for other special characters such as {, <, ", _, - etc.

Please see the attachment for more details.

Any help is greatly appreciated.

Regards,

RK

1 ACCEPTED SOLUTION

Accepted Solutions

Re: NiFi UpdateRecord processor is throwing PatternSyntaxException: Unclosed character class near index 4

Super Guru
@ravi kargam

As a work around Instead of using replaceRegex function use replace function with below configs:

UpdateRecord Configs:

Replacement Value Strategy

Record Path Value

/employeeName

replace(/employeeName,'[','(')

(or)

If you are updating only one column value then

Replacement Value Strategy

Literal Value

/employeeName

${field.value:replaceAll('\\[','(')}
3 REPLIES 3

Re: NiFi UpdateRecord processor is throwing PatternSyntaxException: Unclosed character class near index 4

Super Guru
@ravi kargam

As a work around Instead of using replaceRegex function use replace function with below configs:

UpdateRecord Configs:

Replacement Value Strategy

Record Path Value

/employeeName

replace(/employeeName,'[','(')

(or)

If you are updating only one column value then

Replacement Value Strategy

Literal Value

/employeeName

${field.value:replaceAll('\\[','(')}

Re: NiFi UpdateRecord processor is throwing PatternSyntaxException: Unclosed character class near index 4

New Contributor

Your suggestion worked. Thank you Shu for promptly addressing my issue.

Re: NiFi UpdateRecord processor is throwing PatternSyntaxException: Unclosed character class near index 4

New Contributor

looke like issue in NiFi. created Jira ticket for it

https://issues.apache.org/jira/browse/NIFI-5826