- 2 minutes to read

Formula - regexgroup

The regexgroup('Expression', groups, 'Content') Formula function uses a Regular Expression and a group identifier. You can use this method on all content (Body, Context and output from previous nested Formula functions).

Quick example

Let's get you started with the following example: For other, and more advanced examples please scroll down on this page to the Examples section.

Input Expression Result

ID=123,CUSTOMER=1
ID=456,CUSTOMER=2



regexgroup('ID=(\d+)', '1', body)

123
456
Text Data regex expression Unique values

Features

  • Extract single or multiple unique values from Content.
  • Use any valid RegEx expression.
  • Supports match all, one or selected groups
  • Can be applied on any Content; Like jsonpath, xpath functions, review Formula user guide for the complete list of functions.

This plugin loads the entire message into RAM, so make sure to apply this function only on small messages.

How to use

To use the regexgroup function we have to configure the Formula plugin:

  • Select Formula as the expression type plugin.
  • Write down the expression to use in the 'Expression' text area.
    • Groups can be either a single group (i.e. 1) or multiple groups (i.e. '1,4-6`)
  • Input proper Content as a parameter to the function.

Syntax

Use the regexgroup function with any of the following parameters:

  • From Message Body: regexgroup('Expression',groups, body)

  • From Message Context: regexgroup('Expression',groups, context('id'))

  • Result from previous Formula operation regexgroup('Expression',groups, SomeOtherNestedFormulaFunction(Content))

Examples

Below you will find different common examples of how to use the regexgroup function.

Body as Content

The body is a text "This is number 5", by using the provided expression, the result is 123 and 456.

e.g. regexgroup('ID=(\d+)', '1', body)
RegEx Group Simple Parameter

Message Body


ID=123,CUSTOMER=1
ID=456,CUSTOMER=2

Expression


regexgroup('ID=(\d+)', '1', body)


Context as Content

The Message context value is some text "ORD|101|ExampleCompany1|456|Company Name ACME |Dieselgate valley 1|123 45|Flameburg|" and the key name is "OrderRecord", by using the provided expression, the result is 456

e.g. regexgroup('^(?:(.*?)\|){4}', 1, context('OrderRecord')) RegEx Group Message Context

Message Context Value


	ORD|101|ExampleCompany1|456|Company Name ACME |Dieselgate valley 1|123 45|Flameburg|
 

Expression


regexgroup('^(?:(.*?)\|){4}', 1, context('OrderRecord'))

Next Step

How to Add or manage Search Fields
How to Add or manage Log Views

Expression Type Plugins are used in Search Fields
What are Search Fields?
What are Search Field Expressions?
What are Message Types?
What are Log Views?