SubString
The SubString function allows you to manipulate and extract specific portions of text or characters from a larger string of content.
The substring function can work in two different ways:
■ | When provided with a string text, a start index (an integer), and an optional length (also an integer), it returns a portion of the string text that starts at the specified start index and extends for the given length, if provided. |
■ | If the length is not provided, the function returns the portion of the string text from the start index to the end of the text. |
The SubString function ensures reliability and predictability by returning NULL in the following scenarios:
■ | If the provided input text is not of string type. |
■ | If the start index is equal to or greater than the length of the provided text, indicating an invalid starting point. |
Syntax
SubString(string text, integer start index)
SubString(string text, integer start index, integer length)
Example
SubString("How are you?",8) -> "you?"
SubString("How are you?",4,3) -> "are"
Given that there is a ‘text’ variable saved in the context with the value of “How are you”, you can also use the function as follows:
SubString(${text},8) -> "you?"
SubString(${text},4,3) -> "are"