Formula - startswith
startswith
The core functionality of startswith( )
is to check if text(string) starts with a specific letter or word. the result is true if it matches otherwise return nothing.
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 |
---|---|---|
|
|
true |
Text Data | startswith expression | Unique values |
Syntax
On the Message Body :
startswith('Expression',body)
On the Message Context :
startswith('Expression',context('MessageContextKey'))
Features
- Check matching case at the beginning of a given text.
- Return unique single true value only from Content if the matches occurred.
- Can be applied to any valid Content that return text; 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 startswith function, the Content parameter should contain a text/string (otherwise it will fail and you will end up with a garbage result). But first and foremost 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 startswith function with any of the following parameters:
From Message Body:
startswith(body)
From Message Context:
startswith(context('MessageContextKey'))
Result from previous Formula operation
startswith(SomeOtherNestedFormulaFunction(Content))
Examples
Below you will find different common examples of how to use the startswith function.
Body as Content
The message body is "GMT" normal text, by using the provided expression, the result is true
.
Message Body
GMT
Expression
startswith('G',body)
Context as Content
Example: The message context value for the corresponding key "id" is "GMT", by using the provided expression, the result is true
.
e.g. startswith('G',context('id'))
Message Context Value
GMT
Expression
startswith('G',context('id'))
Formula Function as Content
Regex function used as content parameter of startswith function, by using the provided expression, the result is true
.
e.g. startswith('U,regex('GMT|UTC',body))
Message Body
GMT UTC
Expression
startswith('U,regex('GMT|UTC',body))
Next Step
How to Add or manage Search Fields
How to Add or manage Log Views
Related
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?