blob: 5d620d63b74bcd50bb340963d3e354dc328a50f7 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"></meta><title>ReplaceText</title><link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css"></link></head><script type="text/javascript">window.onload = function(){if(self==top) { document.getElementById('nameHeader').style.display = "inherit"; } }</script><body><h1 id="nameHeader" style="display: none;">ReplaceText</h1><h2>Description: </h2><p>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.</p><h3>Tags: </h3><p>Text, Regular Expression, Update, Change, Replace, Modify, Regex</p><h3>Properties: </h3><p>In the list below, the names of required properties appear in <strong>bold</strong>. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the <a href="../../../../../html/expression-language-guide.html">NiFi Expression Language</a>.</p><table id="properties"><tr><th>Display Name</th><th>API Name</th><th>Default Value</th><th>Allowable Values</th><th>Description</th></tr><tr><td id="name"><strong>Search Value</strong></td><td>Regular Expression</td><td id="default-value">(?s)(^.*$)</td><td id="allowable-values"></td><td id="description">The Search Value to search for in the FlowFile content. Only used for 'Literal Replace' and 'Regex Replace' matching strategies<br/><strong>Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)</strong></td></tr><tr><td id="name"><strong>Replacement Value</strong></td><td>Replacement Value</td><td id="default-value">$1</td><td id="allowable-values"></td><td id="description">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 _).<br/><strong>Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)</strong></td></tr><tr><td id="name"><strong>Character Set</strong></td><td>Character Set</td><td id="default-value">UTF-8</td><td id="allowable-values"></td><td id="description">The Character Set in which the file is encoded</td></tr><tr><td id="name"><strong>Maximum Buffer Size</strong></td><td>Maximum Buffer Size</td><td id="default-value">1 MB</td><td id="allowable-values"></td><td id="description">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 &lt;Replacement Strategy&gt; property is set to one of: Append, Prepend, Always Replace</td></tr><tr><td id="name"><strong>Replacement Strategy</strong></td><td>Replacement Strategy</td><td id="default-value">Regex Replace</td><td id="allowable-values"><ul><li>Prepend <img src="../../../../../html/images/iconInfo.png" alt="Insert the Replacement Value at the beginning of the FlowFile or the beginning of each line (depending on the Evaluation Mode). For &quot;Line-by-Line&quot; Evaluation Mode, the value will be prepended to each line. Similarly, for &quot;First-Line&quot;, &quot;Last-Line&quot;, &quot;Except-Last-Line&quot; and &quot;Except-First-Line&quot; Evaluation Modes,the value will be prepended to header alone, footer alone, all lines except header and all lines except footer respectively. For &quot;Entire Text&quot; evaluation mode,the value will be prepended to the entire text." title="Insert the Replacement Value at the beginning of the FlowFile or the beginning of each line (depending on the Evaluation Mode). For &quot;Line-by-Line&quot; Evaluation Mode, the value will be prepended to each line. Similarly, for &quot;First-Line&quot;, &quot;Last-Line&quot;, &quot;Except-Last-Line&quot; and &quot;Except-First-Line&quot; Evaluation Modes,the value will be prepended to header alone, footer alone, all lines except header and all lines except footer respectively. For &quot;Entire Text&quot; evaluation mode,the value will be prepended to the entire text."></img></li><li>Append <img src="../../../../../html/images/iconInfo.png" alt="Insert the Replacement Value at the end of the FlowFile or the end of each line (depending on the Evaluation Mode). For &quot;Line-by-Line&quot; Evaluation Mode, the value will be appended to each line. Similarly, for &quot;First-Line&quot;, &quot;Last-Line&quot;, &quot;Except-Last-Line&quot; and &quot;Except-First-Line&quot; Evaluation Modes,the value will be appended to header alone, footer alone, all lines except header and all lines except footer respectively. For &quot;Entire Text&quot; evaluation mode,the value will be appended to the entire text." title="Insert the Replacement Value at the end of the FlowFile or the end of each line (depending on the Evaluation Mode). For &quot;Line-by-Line&quot; Evaluation Mode, the value will be appended to each line. Similarly, for &quot;First-Line&quot;, &quot;Last-Line&quot;, &quot;Except-Last-Line&quot; and &quot;Except-First-Line&quot; Evaluation Modes,the value will be appended to header alone, footer alone, all lines except header and all lines except footer respectively. For &quot;Entire Text&quot; evaluation mode,the value will be appended to the entire text."></img></li><li>Regex Replace <img src="../../../../../html/images/iconInfo.png" alt="Interpret the Search Value as a Regular Expression and replace all matches with the Replacement Value. The Replacement Value may reference Capturing Groups used in the Search Value by using a dollar-sign followed by the Capturing Group number, such as $1 or $2. If the Search Value is set to .* then everything is replaced without even evaluating the Regular Expression." title="Interpret the Search Value as a Regular Expression and replace all matches with the Replacement Value. The Replacement Value may reference Capturing Groups used in the Search Value by using a dollar-sign followed by the Capturing Group number, such as $1 or $2. If the Search Value is set to .* then everything is replaced without even evaluating the Regular Expression."></img></li><li>Literal Replace <img src="../../../../../html/images/iconInfo.png" alt="Search for all instances of the Search Value and replace the matches with the Replacement Value." title="Search for all instances of the Search Value and replace the matches with the Replacement Value."></img></li><li>Always Replace <img src="../../../../../html/images/iconInfo.png" alt="Always replaces the entire line or the entire contents of the FlowFile (depending on the value of the &lt;Evaluation Mode&gt; property) and does not bother searching for any value. When this strategy is chosen, the &lt;Search Value&gt; property is ignored." title="Always replaces the entire line or the entire contents of the FlowFile (depending on the value of the &lt;Evaluation Mode&gt; property) and does not bother searching for any value. When this strategy is chosen, the &lt;Search Value&gt; property is ignored."></img></li><li>Substitute Variables <img src="../../../../../html/images/iconInfo.png" alt="Substitute variable references (specified in ${var} form) using FlowFile attributes for looking up the replacement value by variable name. When this strategy is chosen, both the &lt;Search Value&gt; and &lt;Replacement Value&gt; properties are ignored." title="Substitute variable references (specified in ${var} form) using FlowFile attributes for looking up the replacement value by variable name. When this strategy is chosen, both the &lt;Search Value&gt; and &lt;Replacement Value&gt; properties are ignored."></img></li></ul></td><td id="description">The strategy for how and what to replace within the FlowFile's text content.</td></tr><tr><td id="name"><strong>Evaluation Mode</strong></td><td>Evaluation Mode</td><td id="default-value">Line-by-Line</td><td id="allowable-values"><ul><li>Line-by-Line</li><li>Entire text</li></ul></td><td id="description">Run the 'Replacement Strategy' against each line separately (Line-by-Line) or buffer the entire file into memory (Entire Text) and run against that.</td></tr><tr><td id="name">Line-by-Line Evaluation Mode</td><td>Line-by-Line Evaluation Mode</td><td id="default-value">All</td><td id="allowable-values"><ul><li>All</li><li>First-Line</li><li>Last-Line</li><li>Except-First-Line</li><li>Except-Last-Line</li></ul></td><td id="description">Run the 'Replacement Strategy' against each line separately (Line-by-Line) for all lines in the FlowFile, First Line (Header) alone, Last Line (Footer) alone, Except the First Line (Header) or Except the Last Line (Footer).</td></tr></table><h3>Relationships: </h3><table id="relationships"><tr><th>Name</th><th>Description</th></tr><tr><td>success</td><td>FlowFiles that have been successfully processed are routed to this relationship. This includes both FlowFiles that had text replaced and those that did not.</td></tr><tr><td>failure</td><td>FlowFiles that could not be updated are routed to this relationship</td></tr></table><h3>Reads Attributes: </h3>None specified.<h3>Writes Attributes: </h3>None specified.<h3>State management: </h3>This component does not store state.<h3>Restricted: </h3>This component is not restricted.<h3>Input requirement: </h3>This component requires an incoming relationship.<h3>System Resource Considerations:</h3><table id="system-resource-considerations"><tr><th>Resource</th><th>Description</th></tr><tr><td>MEMORY</td><td>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.</td></tr></table></body></html>