String functions string-functions
String functions enable you to manipulate and work with text values within your journey expressions. These functions are essential for text processing, validation, transformation, and analysis in your customer journeys.
Use string functions when you need to:
- Concatenate and combine multiple text values (concat)
- Search for specific text patterns or substrings (contain, containIgnoreCase, indexOf, lastIndexOf, matchRegExp)
- Compare strings with case-sensitive or case-insensitive matching (equalIgnoreCase, notEqualIgnoreCase)
- Check string starts and ends (startWith, startWithIgnoreCase, endWith, endWithIgnoreCase)
- Extract portions of text using substring operations (substr)
- Transform text to uppercase or lowercase (upper, lower, trim)
- Check if strings are empty or contain specific values (isEmpty, isNotEmpty)
- Replace text patterns with new values (replace, replaceAll)
- Split strings into arrays for further processing (split)
- Get string length (length) or generate unique identifiers (uuid)
String functions provide comprehensive text manipulation capabilities, enabling sophisticated data processing and conditional logic based on text content in your journey expressions.
concat concat
Concatenates two string parameters or a list of strings.
concat(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| List | listString |
| string | string |
concat(<string>,<string>)
concat(<listString>)
Returns a string.
concat("Hello","World")
Returns “HelloWorld”.
concat(["Hello"," ","World"])
Returns “Hello World”.
contain contain
Checks if the second argument string is contained in the first argument string.
contain(<parameters>)- string
contain(<string>,<string>)
Returns a boolean.
contain("rowing is great", "great")
Returns true.
containIgnoreCase containIgnoreCase
Checks if the second argument string is contained in the first argument string, without taking into account the case.
containIgnoreCase(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| string | string |
| string searched | string |
containIgnoreCase(<string>,<string>)
Returns a boolean.
containIgnoreCase("rowing is great", "GREAT")
Returns true.
endWith endWith
Returns true if the second parameter is a suffix of the first one.
endWith(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| string | string |
| suffix | string |
endWith(<string>,<string>)
Returns a boolean.
endWith("Hello World", "World")
Returns true.
endWith("Hello World", "Hello")
Returns false.
endWithIgnoreCase endWithIgnoreCase
Checks if the first argument string ends with a specific string (second argument string), not taking into account the case.
endWithIgnoreCase(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| string | string |
| suffix | string |
endWithIgnoreCase(<string>,<string>)
Returns a boolean.
endWithIgnoreCase("rowing is great", "AT")
Returns true.
equalIgnoreCase equalIgnoreCase
Compares the first argument string with the second argument string, ignoring case considerations.
equalIgnoreCase(<parameters>)- string
equalIgnoreCase(<string>,<string>)
Returns a boolean.
equalIgnoreCase("rowing is great", "rowing is GREAT")
Returns true.
indexOf indexOf
Returns the position (in the first argument) of the first occurrence of the second parameter. Returns -1 if there is no match.
indexOf(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| string | String |
| specified value | String |
indexOf(<string>,<string>)
Returns an integer.
indexOf("Hello", "l")
Returns 2.
Explanation:
In “Hello”, the first occurrence of “l” is at position 2.
isEmpty isEmpty
Returns true if the string in the parameter has no character.
isEmpty(<parameters>)- string
isEmpty(<string>)
Returns a boolean.
isEmpty("")
Returns true.
isEmpty("Hello World")
Returns false.
isNotEmpty isNotEmpty
Returns true if the string in the parameter is not empty.
isNotEmpty(<parameters>)- string
isNotEmpty(<string>)
Returns a boolean.
isNotEmpty("")
Returns false.
isNotEmpty("hello")
Returns true.
lastIndexOf lastIndexOf
Returns the position (in the first argument) of the last occurrence of the second parameter. Returns -1 if there is no match.
lastIndexOf(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| string | String |
| specified value | String |
lastIndexOf(<string>,<string>)
Returns an integer.
lastIndexOf("Hello", "l")
Returns 3.
Explanation:
In “Hello”, the last occurrence of “l” is at position 3.
length length
Returns the number of characters of the string expression in the parameter.
length(<parameters>)- string
length(<string>)
Returns an integer.
length("Hello World")
Returns 11.
lower lower
Returns a lowercase version of the parameter.
lower(<parameter>)- string
lower(<string>)
Returns a string.
lower("A")
Returns “a”.
matchRegExp matchRegExp
Returns true if the string in the first parameter matches the regular expression in the second parameter. For more information, see this page.
matchRegExp(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| string | string |
| regexp | string |
matchRegExp(<string>,<string>)
Returns a boolean.
matchRegExp("12345", "\\d+")
Returns true.
notEqualIgnoreCase notEqualIgnoreCase
Check if the first argument string with the second argument string are different, ignoring case considerations.
notEqualIgnoreCase(<parameters>)- string
notEqualIgnoreCase(<string>,<string>)
Returns a boolean.
notEqualIgnoreCase(@event{iOSPushPermissionAllowed.device.model}, "iPad")replace replace
Replaces the first occurrence matching the target string by the replacement string in the base string.
The replacement proceeds from the beginning of the string to the end, for example, replacing “aa” with “b” in the string “aaa” will result in “ba” rather than “ab”.
replace(<parameters>)| table 0-row-2 1-row-2 2-row-2 3-row-2 | |
|---|---|
| Parameter | Type |
| base | string |
| target | string (RegExp) |
| replacement | string |
replace(<base>,<target>,<replacement>)
Return a string.
replace("Hello World", "l", "x")
Returns “Hexlo World”.
Example with RegExp:
Because the target parameter is a RegExp, depending on the string you want to replace, you may need to escape some characters. Here is an example:
- string to evaluate:
|OFFER_A|OFFER_B - provided by a profile attribute
#{ExperiencePlatform.myFieldGroup.profile.myOffers} - String to be replaced:
|OFFER_A - String replaced by:
'' - You need to add
\\before the|character.
The expression is:
replace(#{ExperiencePlatform.myFieldGroup.profile.myOffers}, '\\|OFFER_A', '')
The returned string is: |OFFER_B
You can also build the string to be replaced from a given attribute:
replace(#{ExperiencePlatform.myFieldGroup.profile.myOffers}, '\\|' + #{ExperiencePlatform.myFieldGroup.profile.myOfferCode}, '')
replaceAll replaceAll
Replaces all occurrences matching the target string by the replacement string in the base string.
The replacement proceeds from the beginning of the string to the end, for example, replacing “aa” with “b” in the string “aaa” will result in “ba” rather than “ab”.
replaceAll(<parameters>)| table 0-row-2 1-row-2 2-row-2 3-row-2 | |
|---|---|
| Parameter | Type |
| base | string |
| target | string (RegExp) |
| replacement | string |
replaceAll(<baseString>,<sourceString>,<replacementString>)
Returns a string.
replaceAll("Hello World", "l", "x")
Returns “Hexxo Worxd”.
Because the target parameter is a RegExp, depending on the string you want to replace, you may need to escape some characters. Refer to the example in the replace function.
split split
Splits the first argument string with a separator string (second argument string, which can be a regular expression) to produce a list of strings (tokens).
split(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| input string | string |
| separator string | string |
split(<input string>, <separator string>)
Returns a listString.
split("A_B_C", "_")
Returns ["A","B","C"]
Example with an event field ‘event.appVersion’ with value: “20.45.2.3434”
split(@event{event.appVersion}, "\\.")
Returns ["20", "45", "2", "3434"]
startWith startWith
Returns true if the second parameter is a prefix of the first one.
startWith(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| string | string |
| prefix | string |
startWith(<string>,<string>)
Return a boolean.
startWith("Hello World", "Hello")
Returns true.
startWith("Hello World", "World")
Returns false.
startWithIgnoreCase startWithIgnoreCase
Returns true if the second parameter is a prefix of the first one without considering case.
startWithIgnoreCase(<parameters>)| table 0-row-2 1-row-2 2-row-2 | |
|---|---|
| Parameter | Type |
| string | string |
| prefix | string |
startWithIgnoreCase(<string>,<string>)
Return a boolean.
startWithIgnoreCase("rowing is great", "RO")
Returns true.
substr substr
Returns the sub-string of the string expression between the begin index and the end index. If the end index is not defined, then it is between the begin index and the end.
substr(<parameters>)| table 0-row-2 1-row-2 2-row-2 3-row-2 | |
|---|---|
| Parameter | type |
| string | string |
| beginIndex | integer |
| endIndex | integer |
substr(<string>,<beginIndex>)
substr(<string>,<beginIndex>,<endIndex>)
Return a string.
substr("Hello World",6)
Returns “World”.
substr("Hello World", 0, 5)
Returns “Hello”.
trim trim
Removes start and end spaces.
trim(<parameters>)| table 0-row-2 1-row-2 | |
|---|---|
| Parameter | Type |
| string | string |
trim(<string>)
Return a string.
trim(" Hello ")
Returns “Hello”.
upper upper
Returns an uppercase version of the parameter.
upper(<parameters>)upper(<string>)
Return a string.
upper("b")
Returns “B”.
uuid uuid
Generates a random UUID (Universal Unique IDentifier).
uuid()uuid()
Returns a string.
uuid()
Returns “79e70b7f-8a85-400b-97a1-9f9826121553”.