ExtractText 2.0.0

Bundle
org.apache.nifi | nifi-standard-nar
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 attributes are generated differently based on the enabling of named capture groups. If named capture groups are not enabled: 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.If named capture groups are enabled: Each named capture group, if found will be placed into the attributes name with the name provided. If enabled the matching string sequence itself will be placed into the attribute name. If multiple matches are enabled, and index will be applied after the first set of matches. The exception is a capturing group that is optional and does not match For example, given the attribute name "regex" and expression "abc(?<NAMED>def)?(?<NAMED-TWO>g)" we would add an attribute "regex.NAMED" with the value of "def" if the "def" matched. We would add an attribute "regex.NAMED-TWO" with the value of "g" if the "g" matched regardless. The value of the property must be a valid Regular Expressions with one or more capturing groups. If named capture groups are enabled, all capture groups must be named. If they are not, then the processor configuration will fail validation. If the Regular Expression matches more than once, only the first match will be used unless the property enabling repeating capture group is set to true. 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
Regular Expression, Text, evaluate, extract, regex
Input Requirement
REQUIRED
Supports Sensitive Dynamic Properties
false
  • Additional Details for ExtractText 2.0.0

    ExtractText

    Usage Information

    The Extract Text processor provides different results based on whether named capture groups are enabled.

    Example

    Here is a like for like example that illustrates this.

    Data

        `foo\r\nbar1\r\nbar2\r\nbar3\r\nhello\r\nworld\r\n`
    

    Without named capture groups

    Configuration

    Property Name Property Value
    regex.result1 (?s)(.*)
    regex.result2 (?s).*(bar1).*
    regex.result3 (?s).*?(bar\\d).*
    regex.result4 (?s).*?(?:bar\\d).*?(bar\\d).*?(bar3).*
    regex.result5 (?s).*(bar\\d).*
    regex.result6 (?s)^(.*)$
    regex.result7 (?s)(XXX)

    Results

    Attribute Name Attribute Value
    regex.result1 foo\r\nbar1\r\nbar2\r\nbar3\r\nhello\r\nworld\r\n
    regex.result2 bar1
    regex.result3 bar1
    regex.result4 bar2
    regex.result4.0 foo\r\nbar1\r\nbar2\r\nbar3\r\nhello\r\nworld\r\n
    regex.result4.1 bar2
    regex.result4.2 bar3
    regex.result5 bar3
    regex.result6 foo\r\nbar1\r\nbar2\r\nbar3\r\nhello\r\nworld\r\n
    regex.result7

    With named capture groups

    Configuration

    Property Name Property Value
    Enable named group support True
    regex.result1 (?s)(?.*
    regex.result2 (?s).*(?bar1).*
    regex.result3 (?s).*?(?bar\d).*
    regex.result4 (?s).*?(?:bar\d).*?(?bar\d).*?(?bar3).*
    regex.result5 (?s).*(?bar\d).*
    regex.result6 (?s)^(?.*)$
    regex.result7 (?s)(?XXX)

    Results

    Attribute Name Attribute Value
    regex.result1 foo\r\nbar1\r\nbar2\r\nbar3\r\nhello\r\nworld\r\n
    regex.result2.BAR1 bar1
    regex.result3.BAR1 bar1
    regex.result4.BAR2 bar2
    regex.result4.BAR2 bar2
    regex.result4.BAR3 bar3
    regex.result5.BAR3 bar3
    regex.result6.ALL foo\r\nbar1\r\nbar2\r\nbar3\r\nhello\r\nworld\r\n
    regex.result7.MISS
Properties
Dynamic Properties
Relationships
Name Description
unmatched FlowFiles are routed to this relationship when no provided Regular Expression matches the content of the FlowFile
matched FlowFiles are routed to this relationship when the Regular Expression is successfully evaluated and the FlowFile is modified as a result