- 0 minutes to read

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 example: 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 the complete list of functions.

Important

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 regex 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.
  • Input proper Content as a 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 of 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 is 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 is GMT

e.g. regex('GMT|UTC',context('id')) RegEx Message Context

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 is UTC, CTO.

e.g. regex('UTC|CTO',context(regex('id.*'))) RegEx Message Context Nested Function

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?