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.
Examples
The following are example uses of the Field Calculator (Regular Expression) Processor:
Field value | RegEx pattern | Result |
---|---|---|
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
Keep the following in mind when working with the Field Calculator (Regular Expression) Processor:
- Unlike the Field Calculator Processor, which performs general mathematical, lexical, and logical 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 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
The following are the parameters for the Field Calculator (Regular Expression) Processor:
Parameter | Description |
---|---|
Name |
A descriptive name for the processor used for reference in GeoEvent Manager. |
Processor |
Specifies the processor selected. |
Field Name | The name of the field from the inbound event record used to calculate values. 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 that of 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. Hinweis:Refer to the Examples above for examples of several types of regular expression patterns. |
Target Field | Specifies the target field for the values calculated by the processor. The target field is where the result of the expression is written. The default is Existing Field.
|
New Field Name (Conditional) | The name of the new field where the values calculated by the processor are written. The parameter 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 the following:
This parameter 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. Hinweis: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 Manage tags. The parameter 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 values. The parameter 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 values calculated by the processor are written. Hinweis: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 values calculated by the processor are written. |
Considerations and limitations
The Field Calculator (Regular Expression) Processor does not support back references in the specified regular expression pattern.