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:

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.

Syntax
concat(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2
Parameter Type
List listString
string string
Signature and returned type

concat(<string>,<string>)

concat(<listString>)

Returns a string.

Examples

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.

Syntax
contain(<parameters>)
Parameters
  • string
Signature and returned type

contain(<string>,<string>)

Returns a boolean.

Examples

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.

Syntax
containIgnoreCase(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2
Parameter Type
string string
string searched string
Signature and returned type

containIgnoreCase(<string>,<string>)

Returns a boolean.

Examples

containIgnoreCase("rowing is great", "GREAT")

Returns true.

endWith endWith

Returns true if the second parameter is a suffix of the first one.

Syntax
endWith(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2
Parameter Type
string string
suffix string
Signature and returned type

endWith(<string>,<string>)

Returns a boolean.

Examples

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.

Syntax
endWithIgnoreCase(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2
Parameter Type
string string
suffix string
Signature and returned type

endWithIgnoreCase(<string>,<string>)

Returns a boolean.

Examples

endWithIgnoreCase("rowing is great", "AT")

Returns true.

equalIgnoreCase equalIgnoreCase

Compares the first argument string with the second argument string, ignoring case considerations.

Syntax
equalIgnoreCase(<parameters>)
Parameters
  • string
Signature and returned type

equalIgnoreCase(<string>,<string>)

Returns a boolean.

Examples

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.

Syntax
indexOf(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2
Parameter Type
string String
specified value String
Signature and returned type

indexOf(<string>,<string>)

Returns an integer.

Examples

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.

Syntax
isEmpty(<parameters>)
Parameters
  • string
Signature and returned type

isEmpty(<string>)

Returns a boolean.

Examples

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.

Syntax
isNotEmpty(<parameters>)
Parameters
  • string
Signature and returned type

isNotEmpty(<string>)

Returns a boolean.

Examples

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.

Syntax
lastIndexOf(<parameters>)
Parameter
table 0-row-2 1-row-2 2-row-2
Parameter Type
string String
specified value String
Signature and returned type

lastIndexOf(<string>,<string>)

Returns an integer.

Examples

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.

Syntax
length(<parameters>)
Parameter
  • string
Signature and returned type

length(<string>)

Returns an integer.

Examples

length("Hello World")

Returns 11.

lower lower

Returns a lowercase version of the parameter.

Syntax
lower(<parameter>)
Parameter
  • string
Signature and returned type

lower(<string>)

Returns a string.

Examples

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.

Syntax
matchRegExp(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2
Parameter Type
string string
regexp string
Signature and returned type

matchRegExp(<string>,<string>)

Returns a boolean.

Examples

matchRegExp("12345", "\\d+")

Returns true.

notEqualIgnoreCase notEqualIgnoreCase

Check if the first argument string with the second argument string are different, ignoring case considerations.

Syntax
notEqualIgnoreCase(<parameters>)
Parameters
  • string
Signature and returned type

notEqualIgnoreCase(<string>,<string>)

Returns a boolean.

Examples
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”.

Syntax
replace(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2 3-row-2
Parameter Type
base string
target string (RegExp)
replacement string
Signature and returned type

replace(<base>,<target>,<replacement>)

Return a string.

Examples

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”.

Syntax
replaceAll(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2 3-row-2
Parameter Type
base string
target string (RegExp)
replacement string
Signature and returned type

replaceAll(<baseString>,<sourceString>,<replacementString>)

Returns a string.

Examples

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).

Syntax
split(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2
Parameter Type
input string string
separator string string
Signatures and returned type

split(<input string>, <separator string>)

Returns a listString.

Examples

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.

Syntax
startWith(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2
Parameter Type
string string
prefix string
Signature and returned type

startWith(<string>,<string>)

Return a boolean.

Examples

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.

Syntax
startWithIgnoreCase(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2
Parameter Type
string string
prefix string
Signature and returned type

startWithIgnoreCase(<string>,<string>)

Return a boolean.

Examples

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.

Syntax
substr(<parameters>)
Parameters
table 0-row-2 1-row-2 2-row-2 3-row-2
Parameter type
string string
beginIndex integer
endIndex integer
Signature and returned type

substr(<string>,<beginIndex>)

substr(<string>,<beginIndex>,<endIndex>)

Return a string.

Examples

substr("Hello World",6)

Returns “World”.

substr("Hello World", 0, 5)

Returns “Hello”.

trim trim

Removes start and end spaces.

Syntax
trim(<parameters>)
Parameter
table 0-row-2 1-row-2
Parameter Type
string string
Signature and returned type

trim(<string>)

Return a string.

Examples

trim(" Hello ")

Returns “Hello”.

upper upper

Returns an uppercase version of the parameter.

Syntax
upper(<parameters>)
Signature and returned type

upper(<string>)

Return a string.

Examples

upper("b")

Returns “B”.

uuid uuid

Generates a random UUID (Universal Unique IDentifier).

Syntax
uuid()
Parameters
This function does not require parameters.
Signature and returned type

uuid()

Returns a string.

Examples

uuid()

Returns “79e70b7f-8a85-400b-97a1-9f9826121553”.

AI Knowledge Reference

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 contain or containIgnoreCase
  • Compare two strings while ignoring case using equalIgnoreCase or notEqualIgnoreCase
  • 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 replace or replaceAll
  • 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 isEmpty or isNotEmpty

Glossary:

  • RegExp: A regular expression pattern used as the target parameter in replace, replaceAll, and matchRegExp — 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 target parameter in replace and replaceAll is treated as a RegExp; special characters (e.g., |, .) must be escaped with \\
  • replace replaces only the first matching occurrence; use replaceAll to replace every occurrence
  • isEmpty returns false for null values (not true); null is not considered an empty string
  • indexOf and lastIndexOf return -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 replace and replaceAll?replace substitutes only the first matching occurrence; replaceAll substitutes every occurrence in the string.
  • Q: Why do I need to escape the | character in replace? — 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 isEmpty return true for null? — No, isEmpty returns 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.
recommendation-more-help
journey-optimizer-help