ExtractSignalsByRegEx

ID: Calculate/ExtractSignalsByRegEx


Extracts output signals from an input string signal by applying a regular expression to each value of the input signal.

The values of the output signals can be defined by either all named groups or all unnamed groups in the regular expression.

Signals

InSignal

Input signal the regular expression is applied to. Should be a string signal.

  • Direction: IN

  • Optional: False

OutSignal1

First output signal.

  • Direction: OUT

  • Optional: False

OutSignal2

Second output signal.

  • Direction: OUT

  • Optional: False

OutSignal3

Third output signal.

  • Direction: OUT

  • Optional: False

OutSignal4

Fourth output signal.

  • Direction: OUT

  • Optional: False

OutSignal5

Fifth output signal.

  • Direction: OUT

  • Optional: False

Parameters

RegEx

Regular expression that is applied to the input signal to extract the output signals. The output signals can either be defined by all named groups with the names of the output signals (OutSignal1, …) or all unnamed groups. If named groups are used, unnamed groups are ignored. If no named groups are used, groups that should not result in an output signal must be non-capturing groups, e.g.

  • named group: (?P<OutSignal1>.+)

  • unnamed group: (.+)

  • non-capturing group: (?:.+)

  • Direction: IN

DataTypes

Either a tuple/list of individual type specifications for each signal or one for all signals. A type specification can be either:

  • the keyword ‘auto’ for auto detection

  • one of the simple data types int, float, bool or str

  • a user defined function that converts the input string found by the regular expression to an output value of the desired type, e.g.

    def func(x):

    return x in (‘yes’, ‘y’, ‘x’, ‘True’, ‘true’)

Valid values for the parameter are, for example:

  • float

  • (int, float, str, ‘auto’)

Hint: A conversion to bool is possible for integers (False if zero, else True) or strings only containing ‘True’ and ‘False’ (case insensitive). If ‘auto’ is selected, integers are not converted to Booleans automatically.

  • Direction: IN

ErrorOnUnmatchedValues

If set, the verdict is set to ERROR if at least one input value did not match the regular expression. If not set, the output signals will just have no values at the corresponding timestamp.

Default: True

Hint: Optional groups are not influenced by this setting. If there is a match, but the optional group does not exist, the corresponding output signal just has no value at the concerning timestamp and the verdict is not set to ERROR independent from this setting.

  • Direction: IN