Formula - substring

substring(startIndex,length,Content) Formula function is used to extract/slice specific text from any given text.

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

nodinite


substring(0,4,body)

nodi
Text Data substring expression Unique values

Features

  • Slice/extract a given text from Content.
  • The user must set the start index (0-based).
  • The length must be set (number of characters to include).
  • Can be applied on any valid Content that return text; 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 substring function the Content parameter should contain a text (otherwise it will fail and you will end up with nothing). But first and foremost 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 base64decode function with any of the following parameters:

  • From Message Body: substring(startIndex,length,body)

  • From Message Context: substring(startIndex,length,context('MessageContextKey'))

  • Result from previous Formula operation substring(startIndex,length,SomeOtherNestedFormulaFunction(Content))

Examples

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

Body as Content

"nodinite" is the body content, by using the provided expression the result will be nodi.

e.g. substring(0,4,body)

Simple Content parameter_substring

Message Body


 nodinite

Expression


nodi


Context as Content

"Amazing Function" is the Message Context value and the key is "id", by using the provided expression the result will be Amazing.

e.g. substring(0,7,context('id'))

Simple Content parameter_substring

Message Context Value


Amazing Function

Expression


substring(0,7,context('id'))



Formula Function as Content

Body content is json array and the Content parameter is jsonpath function, by using the provided expression the result will be Co ,ol.

e.g. substring(0,2,jsonpath('$..name',body))

nested Content parameter_substring

Message Body


[	
	{ "name" :"column"},
	{"name" :"olive"}
]

Expression


substring(0,2,jsonpath('$..name',body))


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?