Expression Language
Also available as:
PDF

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:

Arguments:

  • Regex : he 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:

Table 1.10. Table 10. ReplaceAll Examples

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