ReplaceText 2.0.0

Bundle
org.apache.nifi | nifi-standard-nar
Description
Updates the content of a FlowFile by searching for some textual value in the FlowFile content (via Regular Expression/regex, or literal value) and replacing the section of the content that matches with some alternate value. It can also be used to append or prepend text to the contents of a FlowFile.
Tags
Change, Modify, Regex, Regular Expression, Replace, Text, Update
Input Requirement
REQUIRED
Supports Sensitive Dynamic Properties
false
Properties
System Resource Considerations
Resource Description
MEMORY An instance of this component can cause high usage of this system resource. Multiple instances or high concurrency settings may result a degradation of performance.
Relationships
Name Description
failure FlowFiles that could not be updated are routed to this relationship
success FlowFiles that have been successfully processed are routed to this relationship. This includes both FlowFiles that had text replaced and those that did not.
Use Cases
  • Append text to the end of every line in a FlowFile
    Description
    Append text to the end of every line in a FlowFile
    Keywords
    raw text, append, line
    Configuration
    "Evaluation Mode" = "Line-by-Line"
    "Replacement Strategy" = "Append"
    
    "Replacement Value" is set to whatever text should be appended to the line.
    For example, to insert the text `<fin>` at the end of every line, we would set "Replacement Value" to `<fin>`.
    We can also use Expression Language. So to insert the filename at the end of every line, we set "Replacement Value" to `${filename}`
    
  • Prepend text to the beginning of every line in a FlowFile
    Description
    Prepend text to the beginning of every line in a FlowFile
    Keywords
    raw text, prepend, line
    Configuration
    "Evaluation Mode" = "Line-by-Line"
    "Replacement Strategy" = "Prepend"
    
    "Replacement Value" is set to whatever text should be prepended to the line.
    For example, to insert the text `<start>` at the beginning of every line, we would set "Replacement Value" to `<start>`.
    We can also use Expression Language. So to insert the filename at the beginning of every line, we set "Replacement Value" to `${filename}`
    
  • Replace every occurrence of a literal string in the FlowFile with a different value
    Description
    Replace every occurrence of a literal string in the FlowFile with a different value
    Keywords
    replace, string, text, literal
    Configuration
    "Evaluation Mode" = "Line-by-Line"
    "Replacement Strategy" = "Literal Replace"
    "Search Value" is set to whatever text is in the FlowFile that needs to be replaced.
    "Replacement Value" is set to the text that should replace the current text.
    
    For example, to replace the word "spider" with "arachnid" we set "Search Value" to `spider` and set "Replacement Value" to `arachnid`.
    
  • Transform every occurrence of a literal string in a FlowFile
    Description
    Transform every occurrence of a literal string in a FlowFile
    Keywords
    replace, transform, raw text
    Configuration
    "Evaluation Mode" = "Line-by-Line"
    "Replacement Strategy" = "Regex Replace"
    "Search Value" is set to a regular expression that matches the text that should be transformed in a capturing group.
    "Replacement Value" is set to a NiFi Expression Language expression that references `$1` (in quotes to escape the reference name).
    
    For example, if we wanted to lowercase any occurrence of WOLF, TIGER, or LION, we would use a "Search Value" of `(WOLF|TIGER|LION)` and a "Replacement Value" of `${'$1':toLower()}`.
    If we want to replace any identifier with a hash of that identifier, we might use a "Search Value" of `identifier: (.*)` and a "Replacement Value" of `identifier: ${'$1':hash('sha256')}`
    
  • Completely replace the contents of a FlowFile to a specific text
    Description
    Completely replace the contents of a FlowFile to a specific text
    Keywords
    replace, raw text
    Configuration
    "Evaluation Mode" = "Entire text"
    "Replacement Strategy" = "Always Replace"
    
    "Replacement Value" is set to the new text that should be written to the FlowFile. This text might include NiFi Expression Language to reference one or more attributes.