Description:

Evaluates one or more Regular Expressions against the content of a FlowFile. The results of those Regular Expressions are assigned to FlowFile Attributes. Regular Expressions are entered by adding user-defined properties; the name of the property maps to the Attribute Name into which the result will be placed. The first capture group, if any found, will be placed into that attribute name.But all capture groups, including the matching string sequence itself will also be provided at that attribute name with an index value provided, with the exception of a capturing group that is optional and does not match - for example, given the attribute name “regex” and expression “abc(def)?(g)” we would add an attribute “regex.1” with a value of “def” if the “def” matched. If the “def” did not match, no attribute named “regex.1” would be added but an attribute named “regex.2” with a value of “g” will be added regardless.The value of the property must be a valid Regular Expressions with one or more capturing groups. If the Regular Expression matches more than once, only the first match will be used. If any provided Regular Expression matches, the FlowFile(s) will be routed to ‘matched’. If no provided Regular Expression matches, the FlowFile will be routed to ‘unmatched’ and no attributes will be applied to the FlowFile.

Tags:

evaluate, extract, Text, Regular Expression, regex

Properties:

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.

Name Default Value Allowable Values Description
Command Arguments The arguments to supply to the executable delimited by the ';' character.
Supports Expression Language: true
Command Path Specifies the command to be executed; if just the name of an executable is provided, it must be in the user's environment PATH.
Supports Expression Language: true
Ignore STDIN false * true
* false
If true, the contents of the incoming flowfile will not be passed to the executing command
Enable Canonical Equivalence false * true
* false
Indicates that two characters match only when their full canonical decompositions match.
Argument Delimiter ; Delimiter to use to separate arguments for a command [default: ;]. Must be a single character
false * true
* false
In this mode, whitespace is ignored, and embedded comments starting with # are ignored until the end of a line. Can also be specified via the embeded flag (?x).
Enable DOTALL Mode false * true
* false
Indicates that the expression '.' should match any character, including a line terminator. Can also be specified via the embeded flag (?s).
Enable Literal Parsing of the Pattern false * true
* false
Indicates that Metacharacters and escape characters should be given no special meaning.
Enable Multiline Mode false * true
* false
Indicates that '^' and '$' should match just after and just before a line terminator or end of sequence, instead of only the begining or end of the entire input. Can also be specified via the embeded flag (?m).
Enable Unicode-aware Case Folding false * true
* false
When used with 'Enable Case-insensitive Matching', matches in a manner consistent with the Unicode Standard. Can also be specified via the embeded flag (?u).
Enable Unicode Predefined Character Classes false * true
* false
Specifies conformance with the Unicode Technical Standard #18: Unicode Regular Expression Annex C: Compatibility Properties. Can also be specified via the embeded flag (?U).
Enable Unix Lines Mode false * true
* false
Indicates that only the ' ' line terminator is recognized in the behavior of '.', '^', and '$'. Can also be specified via the embeded flag (?d).
Include Capture Group 0 true * true
* false
Indicates that Capture Group 0 should be included as an attribute. Capture Group 0 represents the entirety of the regular expression match, is typically not used, and could have considerable length.

Dynamic Properties:

Dynamic Properties allow the user to specify both the name and value of a property.

Name Value Description
A FlowFile attribute A Regular Expression with one or more capturing group The first capture group, if any found, will be placed into that attribute name.But all capture groups, including the matching string sequence itself will also be provided at that attribute name with an index value provided.

Relationships:

Name Description
matched FlowFiles are routed to this relationship when the Regular Expression is successfully evaluated and the FlowFile is modified as a result
unmatched FlowFiles are routed to this relationship when no provided Regular Expression matches the content of the FlowFile

Reads Attributes:

None specified.

Writes Attributes:

None specified.

How to configure?

Step 1: Drag and drop the ExtractText processor to canvas.

Step 2: Double click the processor to configure, the configuration dialog will be opened as follows,

properties

Step 3: Check the usage of each property and update those values.

Properties and usage

Character Set: Enters the character set of the file to be extracted.

Maximum Buffer Size: Specifies the maximum size of the data to be buffered in file.

Maximum Capture Group Length: Strategy for replacing flow file content.

Enable Case-insensitive Matching: Enables the matching characters even when they are in different cases.

Evaluation Mode: Used to load entire file and search with replacement strategy or evaluate each line separately.

For example,to get the flow file content and store it as flow file attribute add attribute as follows,

sample