Skip To Content

Field Calculator (Regular Expression) Processor

Summary

The Field Calculator (Regular Expression) Processor can be used to leverage the power of regular expressions to identify a pattern within a target field and extract the substrings from received events. The extracted substrings are either written back to the target field, replacing the field’s original value, or written to a new field. The processor does not support the general mathematic, lexical, and logical expressions supported by the Field Calculator Processor.

Examples

Field valueRegEx patternResult

SWA2382

^SWA[0-9]+$

The carat sign (^) anchors the pattern to the beginning of the string and the dollar sign ($) anchors the pattern to the end of the string. The [0-9]+ portion of the pattern specifies one or more digits, 0 through 9, should be found at the end of the string.

Any values in the target field that do not begin with SWA, followed by some number of digits representing a flight number, will not be extracted as a substring by the processor.

02/15/1973

[0-1][0-9][/][0-3][0-9][/][0-1][0-9][0-9][0-9]

The use of numeric ranges such as 0 through 1, 0 through 3, and 0 through 9 specifies the expected values for a mm/dd/yy date string. Values that do not have a two-digit month followed by a two-digit day and a four-digit year, separated by a forward slash (/), will not be extracted as a substring by the processor.

3.14159

^[-+]?[0-9]*\.?[0-9]+$

This pattern verifies the string in the target field can be interpreted as a numeric value. An asterisk (*) in the RegEx pattern matches zero or more instances of the preceding character; a question mark (?) matches zero or one instance. The backslash (\) means the period (.) is a literal decimal point, not a wildcard (*). The pattern makes a plus (+) or minus (-) sign the integer portion of a floating-point value and the literal decimal optional (may occur zero times).

Alpha

^.{0,5}

The carat sign (^) anchors the pattern to the beginning of the string and the period (.) is a wildcard matching any character. The {0,5} indicates that a substring, with a minimum length of 0 and a maximum length of 5, will be returned as the matched pattern.

This RegEx pattern can be used to return a fixed number of characters in support of a new field that has a character limit threshold. Applying the RegEx pattern to a field whose value is AlphaBeta will return just the substring Alpha. Alpha is the first 5 characters of the string AlphaBeta.

Usage notes

  • Unlike the Field Calculator Processor, which performs mathematical or lexical calculations using different expressions, the Field Calculator (Regular Expression) Processor only identifies and extracts substrings of a target field using regular expression patterns.
  • When specifying a target field for a regular expression pattern to evaluate, the required syntax is ${…} where is the name of the field encased by ${}. This contrasts with the Field Calculator Processor which expects fields to be defined using just the name.
  • The processor can be configured to store the output substring in an existing field or a new field using the Target Field parameter. Altering an event record's schema by adding a new field requires GeoEvent Server to create a new GeoEvent Definition. The new GeoEvent Definition will be managed by GeoEvent Server and deleted if changes are made to the processor or the GeoEvent Service in which the processor is used.

Parameters

ParameterDescription

Name

A descriptive name for the processor used for reference in GeoEvent Manager.

Processor

The name of the selected processor.

Field Name

The name of the field from the inbound event record used to calculate values from. There is no default for this parameter.

The required syntax for identifying fields is ${…} where is the name of the field encased by ${}. An example of this would be ${Description}. The syntax for referencing field names using the processor is different than the Field Calculator Processor, which expects event record field names without encasement.

Pattern

The regular expression used to identify a pattern from the event record target field as specified by the Field Name parameter. The processor uses the pattern to identify and extract a substring from the event record target field.

Remarque :

Refer to the Examples above for examples of several different types of regular expression patterns.

Target Field

Specifies the target field for the value(s) calculated by the processor. The target field is where the result of the expression will be written to. The default is Existing Field.

  • Existing Field - The target field is an existing field. The value(s) calculated by the processor will be stored in an existing field from the event record.
  • New Field - The target field is a new field. The value(s) calculated by the processor will be stored in a new field. Altering an event record’s schema by adding a new field requires a new GeoEvent Definition.

New Field Name

(Conditional)

The name of the new field where the value(s) calculated by the processor will be written to.

Property is shown when Target Field is set to New Field and is hidden when set to Existing Field.

New Field Type

(Conditional)

Specifies the data type of the new field created by the processor. The default is Boolean. Available data types include:

  • Boolean
  • Date
  • Double
  • Float
  • Geometry
  • Integer
  • Long
  • Short
  • String

Property is shown when Target Field is set to New Field and is hidden when set to Existing Field.

New Field Tag

(Conditional)

The name of an existing field tag that will be applied to the new field. There is no default for this parameter.

Remarque :

The tag must already exist for the new field to be tagged. The processor does not dynamically create tags. For more information on managing and creating tags, see Managing tags.

Property is shown when Target Field is set to New Field and is hidden when set to Existing Field.

New GeoEvent Definition Name

(Conditional)

The name assigned to the new GeoEvent Definition. The new GeoEvent Definition will combine the schema of the inbound event record with the new field used for storing the calculated value(s).

Property is shown when Target Field is set to New Field and is hidden when set to Existing Field.

Existing Field Name

The name of an existing field where the value(s) calculated by the processor will be written to. There is no default value for this parameter.

Remarque :

Use the Definition menu to identify the GeoEvent Definition of the inbound event records. Choosing a GeoEvent Definition will narrow the scope of available fields to choose from. Use the Field menu to identify the specific name of the existing field where the value(s) calculated by the processor will be written to.

Considerations and limitations

  • The Field Calculator (Regular Expression) Processor does not support back references within the specified regular expression pattern.