Updates the content of a FlowFile by evaluating a Regular Expression (regex) against it and replacing the section of the content that matches the Regular Expression with some alternate value.
Text, Regular Expression, Update, Change, Replace, Modify, Regex
In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the Expression Language Guide.
|Name||Default Value||Allowable Values||Description|
The Search Value to search for in the FlowFile content. Only used for 'Literal Replace' and 'Regex Replace' matching strategies
Supports Expression Language: true
The value to insert using the 'Replacement Strategy'. Using "Regex Replace" back-references to Regular Expression capturing groups are supported, but back-references that reference capturing groups that do not exist in the regular expression will be treated as literal value. Back References may also be referenced using the Expression Language, as '$1', '$2', etc. The single-tick marks MUST be included, as these variables are not "Standard" attribute names (attribute names must be quoted unless they contain only numbers, letters, and _).
Supports Expression Language: true
|Character Set||UTF-8||The Character Set in which the file is encoded|
|Maximum Buffer Size||1 MB||Specifies the maximum amount of data to buffer (per file or per line, depending on the Evaluation Mode) in order to apply the replacement. If 'Entire Text' (in Evaluation Mode) is selected and the FlowFile is larger than this value, the FlowFile will be routed to 'failure'. In 'Line-by-Line' Mode, if a single line is larger than this value, the FlowFile will be routed to 'failure'. A default value of 1 MB is provided, primarily for 'Entire Text' mode. In 'Line-by-Line' Mode, a value such as 8 KB or 16 KB is suggested. This value is ignored if the <Replacement Strategy> property is set to one of: Append, Prepend, Always Replace|
|Replacement Strategy||Regex Replace||
*Prepend <img src="ReplaceText_images/ReplaceText_img1.jpeg" title="Insert the Replacement Value at the beginning of the FlowFile or the beginning of each line (depending on the Evaluation Mode). For "Line-by-Line" Evaluation Mode, the value will be prepended to each line. For "Entire Text" evaluation mode, the value will be prepended to the entire text."/>
*Append <img src="ReplaceText_images/ReplaceText_img1.jpeg" title="Insert the Replacement Value at the end of the FlowFile or the end of each line (depending on the Evluation Mode). For "Line-by-Line" Evaluation Mode, the value will be appended to each line. For "Entire Text" evaluation mode, the value will be appended to the entire text."/>
|The strategy for how and what to replace within the FlowFile's text content.|
|Evaluation Mode||Entire text||
|Run the 'Replacement Strategy' against each line separately (Line-by-Line) or buffer the entire file into memory (Entire Text) and run against that.|
|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.|
How to configure?
Step 1: Drag and drop the ReplaceText processor to canvas.
Step 2: Double click the processor to configure. The configuration dialog will be opened as follows:
Step 3: Check the usage of each property and update those values.
Properties and usage
Search Value: Enters the value to be searched in flow file content using this property. It supports regex expression as well as plain text.
Replacement Value: Enters the value to be replaced with searched value.
Character Set: Used to mention the character set in which the flow file is encoded.
Maximum Buffer Size: Specifies the maximum amount of data to buffer (per file or per line, depending on the evaluation mode) to replace.
Replacement Strategy: Strategy for replacing flow file content.
Evaluation Mode: Used to specify whether to load the entire file and search with replacement strategy or evaluate each line separately.
For example, if you want to remove all the square brackets in the flow file content mention the search value using the regex expression ]|[(.*?).