Skip to content

Regex selection¤

Description¤

This transformer takes three inputs: a single output value, a sequence of regular expressions and a sequence of values to check against the regular expressions. It returns a sequence of copies of the output value exclusively at those positions where one of the regular expressions matches the input value.

In other words: It selects the matches within the sequence of values against the regular expressions and ‘marks’ them with the provided output value.

As a further detail of its operation: If the parameter oneOnly of the transformer is set to true, then only the position of the first matching regular expression will be marked with the output value. There won’t be any further marked matches.

Notes on regular expressions¤

The most commonly used examples of regular expressions are "\\s*" for representing whitespace characters, [^0-9]* for numbers, and [a-z]* for the usual English characters between a and z. The star (*) represents an arbitrary number of occurrences (zero included), whereas the plus sign (+) indicates a strictly positive number of occurrences (zero excluded).

An uppercase version of the predefined character classes means negation, such as "\\S*" for non-whitespace characters, or "\\D*" for non-digits. Similarly, the hat sign ^ can be used for negating (arbitrary) character classes, such as [^xyz] for any character except x, y or z.

Attention: Slashes in regular expressions have to be escaped, e.g. instead of \s we need to escape it as \\s.

Note for advanced users¤

A compilation of the available constructs for building regular expressions is available in the API of the Java Pattern.

Relation to other plugins¤

Additionally to the regexSelect plugin, there are related plugins such as ifMatchesRegex, validateRegex, regexReplace and regexExtract.

The distinctive feature of each of these plugins lies in what happens whenever the regular expression matches the input value(s): the ifMatchesRegex plugin is useful for conditionally distinguishing which input to take, validateRegex is used for validating the input, regexReplace replaces all occurrences, and regexExtract extracts them.

Examples¤

Notation: List of values are represented via square brackets. Example: [first, second] represents a list of two values “first” and “second”.


sets the correct outputs based on the regexes:

  • Parameters

    • oneOnly: false
  • Input values:

    1. [output]
    2. [a, b, c]
    3. [catch]
  • Returns: [output, , output]


return only first match position if oneOnly = true:

  • Parameters

    • oneOnly: true
  • Input values:

    1. [output]
    2. [a, b, c]
    3. [catch]
  • Returns: [output, , ]

Parameter¤

One only¤

No description

  • ID: oneOnly
  • Datatype: boolean
  • Default Value: false

Advanced Parameter¤

None

Comments