Formula - regex

The regex('Expression','Content') Formula function implemented Regular Expression as it is implemented everywhere. In other words, as long as the first parameter of the regex('Expression','Content') is a valid Regular Expression the function will return the matched result.

Quick example

Let's get you started with the following simple demonstration example valid for this Formula plugin. For other and more advanced examples please scroll down on this page to the Examples section.

Input Expression Result

 This is number 5


regex('\d+',body)

5
Text Data regex expression Unique values

Features

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

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

How to use

In order to use the regex function we have to configure the Formula plugin:

  • Select Formula as expression type plugin.
  • Write down the expression to use in the 'Expression' text area.
  • Input a proper Content as parameter to the function.

Syntax

Use the regex function with any of the following parameters:

  • From Message Body: regex('Expression',body)

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

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

Examples

Below you will find different common examples for how to use the regex function.

Body as Content

The body is a text "This is number 5", by using the provided expression the result will be 5.

e.g. regex('\d+',body)
regex_simpleParameter

Message Body


  This is number 5

Expression


regex('\d+',body)


Context as Content

The Message context value is normal text "GMT" and the key is "id", by using the provided expression the result will be GMT

e.g. regex('GMT|UTC',context('id')) regex_MessageContext

Message Context Value


	GMT
 

Expression


regex('GMT|UTC',context('id'))


Formula Function as Content

The Message Context value is normal text, we applied regex function on Key field to get multiple values and return list of matches, by using the provided expression the result will be UTC, CTO.

e.g. regex('UTC|CTO',context(regex('id.*'))) regex_messageContext_nestedFunction

Message Body


GMT UTC


GMT CTO

Expression


regex('UTC|CTO',context(regex('id.*')))


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?