Apache NiFi Expression Language GuidePDF version

replaceAll

Description: The replaceAll function takes two String arguments: a literal String or Regular Expression (NiFi uses the Java Pattern syntax), and a replacement string. The return value is the result of substituting the replacement string for all patterns within the Subject that match the Regular Expression.

Subject Type: String

Arguments:

  • Regex : The Regular Expression (in Java syntax) to match in the Subject

  • Replacement : The value to use for replacing matches in the Subject. If the regular expression argument uses Capturing Groups, back references are allowed in the replacement.

Return Type: String

Examples: If the "filename" attribute has the value "a brand new filename.txt", then the following Expressions will provide the following results:

Expression

Value

${filename:replaceAll('\..*', '')}

a brand new filename

${filename:replaceAll('a brand (new)', '$1')}

new filename.txt

${filename:replaceAll('XYZ', 'ZZZ')}

a brand new filename.txt

${filename:replaceAll('brand (new)', 'somewhat $1')}

a somewhat new filename.txt

We want your opinion

How can we improve this page?

What kind of feedback do you have?