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.
isEmpty(<null>)
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”.
This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.
For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.
- TL;DR: This page documents all string functions available in AJO journey expressions, covering text search, comparison, transformation, extraction, validation, replacement, splitting, and unique identifier generation.
Intents:
- Concatenate two or more strings using
concat - Search for a substring within a string (case-sensitive or case-insensitive) using
containorcontainIgnoreCase - Compare two strings while ignoring case using
equalIgnoreCaseornotEqualIgnoreCase - Check whether a string starts or ends with a specific prefix or suffix using
startWith,endWith, and their case-insensitive variants - Extract a substring by index positions using
substr - Replace the first or all occurrences of a pattern in a string using
replaceorreplaceAll - Split a string into a list of tokens by a separator using
split - Generate a random UUID for unique identifier needs using
uuid - Check if a string is empty or non-empty using
isEmptyorisNotEmpty
Glossary:
- RegExp: A regular expression pattern used as the target parameter in
replace,replaceAll, andmatchRegExp— special characters must be escaped with\\ - UUID: Universal Unique IDentifier — a randomly generated string identifier returned by
uuid() - substr: Extracts a portion of a string by specifying a start index and optional end index (zero-based)
Guardrails:
- The
targetparameter inreplaceandreplaceAllis treated as a RegExp; special characters (e.g.,|,.) must be escaped with\\ replacereplaces only the first matching occurrence; usereplaceAllto replace every occurrenceisEmptyreturns false for null values (not true); null is not considered an empty stringindexOfandlastIndexOfreturn -1 when no match is found- String index positions are zero-based (the first character is at position 0)
Terminology:
- Canonical name: String functions — Acronym: none — variants: text functions, string manipulation functions
- Synonyms: “contain” = “substring check”; “split” = “tokenize string”; “trim” = “strip whitespace”
- Do not confuse: “replace” (first occurrence only) ≠ “replaceAll” (all occurrences)
- Do not confuse: “indexOf” (first occurrence position) ≠ “lastIndexOf” (last occurrence position)
- Do not confuse: “isEmpty” (true only for zero-length string) ≠ null check (isEmpty returns false for null)
- Do not confuse: “equalIgnoreCase” (returns true when equal ignoring case) ≠ “notEqualIgnoreCase” (returns true when different ignoring case)
FAQ:
- Q: How do I check if a string contains a substring regardless of case? — Use
containIgnoreCase("myString", "searchTerm"), which returns true if the search term is found in any case. - Q: What is the difference between
replaceandreplaceAll? —replacesubstitutes only the first matching occurrence;replaceAllsubstitutes every occurrence in the string. - Q: Why do I need to escape the
|character inreplace? — The target parameter is treated as a regular expression;|is a special RegExp character and must be escaped as\\|to be treated as a literal pipe. - Q: Does
isEmptyreturn true for null? — No,isEmptyreturns false for null; it only returns true for a zero-length string"". - Q: How do I extract the major version number from a version string like “20.45.2.3434”? — Use
getListItem(split(@event{event.appVersion}, "\\."), 0)to split by dot and retrieve the first element. - Q: How do I generate a unique identifier in a journey expression? — Use
uuid(), which returns a randomly generated UUID string with no parameters required.