String Functions

Learn how to use String functions in the Expression Editor.

Camel Case

The camelCase function capitalizes the first letter of each word of a string.

Format

{%= camelCase(string)%}

Example

The following function will capitalize the first letter of word in the profile’s street address.

{%= camelCase(profile.homeAddress.street) %}

Concat

The concat function combines two strings into one.

Format

{%= concat(string,string) %}

Example

The following function will combine profile city and country in a single string.

{%= concat(profile.homeAddress.city,profile.homeAddress.country) %}

Contains

The contains function is used to determine if a string contains a specified substring.

Format

{%= contains(STRING_1, STRING_2, CASE_SENSITIVE) %}
Argument Description
STRING_1 The string to perform the check on.
STRING_2 The string to search for within the first string.
CASE_SENSITIVE An optional parameter to determine if the check is case sensitive. Possible values: true (default) / false.

Examples

  • The following function will check if the profile first name contains the letter A (in upper or lower case). If this is the case, it will return ‘true’, else it will return ‘false’.

    {%= contains(profile.person.name.firstName, "A", false) %}
    
  • The following query determines, with case sensitivity, if the person’s email address contains the string “2010@gm”.

    {%= contains(profile.person.emailAddress,"2010@gm") %}
    

Does not contain

The doesNotContain function is used to determine if a string does not contain a specified substring.

Format

{%= doesNotContain(STRING_1, STRING_2, CASE_SENSITIVE)%}
Argument Description
STRING_1 The string to perform the check on.
STRING_2 The string to search for within the first string.
CASE_SENSITIVE An optional parameter to determine if the check is case sensitive. Possible values: true (default) / false.

Example

The following query determines, with case sensitivity, if the person’s email address does not contain the string “2010@gm”.

{%= doesNotContain(profile.person.emailAddress,"2010@gm")%}

Does not end with

The doesNotEndWith function is used to determine if a string does not end with a specified substring.

Format

{%= doesNotEndWith(STRING_1, STRING_2, CASE_SENSITIVE)%}
Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The string to search for within the first string.
{CASE_SENSITIVE} An optional parameter to determine if the check is case sensitive. Possible values: true (default) / false.

Example

The following query determines, with case sensitivity, if the person’s email address does not end with “.com”.

doesNotEndWith(person.emailAddress,".com")

Does not start with

The doesNotStartWith function is used to determine if a string does not start with a specified substring.

Format

{%= doesNotStartWith(STRING_1, STRING_2, CASE_SENSITIVE)%}
Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The string to search for within the first string.
{CASE_SENSITIVE} An optional parameter to determine if the check is case sensitive. Possible values: true (default) / false.

Example

The following query determines, with case sensitivity, if the person’s name does not start with “Joe”.

{%= doesNotStartWith(person.name,"Joe")%}

Encode 64

The encode64 function is used to encode a string to preserve Personal Information (PI) if to be included for example in a URL.

Format

{%= encode64(string) %}

Ends with

The endsWith function is used to determine if a string ends with a specified substring.

Format

{%= endsWith(STRING_1, STRING_2, CASE_SENSITIVE) %}
Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The string to search for within the first string.
{CASE_SENSITIVE} An optional parameter to determine if the check is case sensitive. Possible values: true (default) / false.

Example

The following query determines, with case sensitivity, if the person’s email address ends with “.com”.

{%= endsWith(person.emailAddress,".com") %}

Equals

The equals function is used to determine if a string is equal to the specified string, with case sensitivity.

Format

{%= equals(STRING_1, STRING_2) %}
Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The string to compare with the first string.

Example

The following query determines, with case sensitivity, if the person’s name is “John”.

{%=equals(profile.person.name,"John") %}

Equals Ignore Case

The equalsIgnoreCase function is used to determine if a string is equal to the specified string, without case sensitivity.

Format

{%= equalsIgnoreCase(STRING_1, STRING_2) %}
Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The string to compare with the first string.

Example

The following query determines, without case sensitivity, if the person’s name is “John”.

{%= equalsIgnoreCase(profile.person.name,"John") %}

Extract Email Domain

The extractEmailDomain function is used to extract the domain of an email address.

Format

{%= extractEmailDomain(string) %}

Example

The following query extracts the email domain of the personal email address.

{%= extractEmailDomain(profile.personalEmail.address) %}

Is empty

The isEmpty function is used to determine of a string is empty.

Format

{%= isEmpty(string) %}

Example

The following function returns ‘true’ if the profile’s mobile phone number is empty. Else, it will return ‘false’.

{%= isEmpty(profile.mobilePhone.number) %}

Left trim

The leftTrim function is used to remove white spaces from beginning of a string.

Format

{%= leftTrim(string) %}

Length

The length function is used to get the number of characters in a string or an expression.

Format

{%= length(string) %}

Example

The following function returns the length of the profile’s city name.

{%= length(profile.homeAddress.city) %}

Like

The like function is used to determine if a string matches a specified pattern.

Format

{%= like(STRING_1, STRING_2) %}
Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The expression to match against the first string. There are two supported special characters for creating an expression: % and _.
  • % is used to represent zero or more characters.
  • _ is used to represent exactly one character.

Example

The following query retrieves all the cities where profiles live containing the pattern “es”.

{%= like(profile.homeAddress.city, "%es%")%}

Lower Case

The lowerCase function converts a string to lower case letters.

Syntax

{%= lowerCase(string) %}

Example

This function converts the profile first name to lower case letters.

{%= lowerCase(profile.person.name.firstName) %}

Matches

The matches function is used to determine if a string matches a specific regular expression. Please refer to this document for more information on matching patterns in regular expressions.

Format

{%= matches(STRING_1, STRING_2) %}

Example

The following query determines, without case sensitivity, if the person’s name starts with “John”.

{%= matches(person.name.,"(?i)^John") %}

Not equal to

The notEqualTo function is used to determine if a string is not equal to the specified string.

Format

{%= notEqualTo(STRING_1, STRING_2) %}
Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The string to compare with the first string.

Example

The following query determines, with case sensitivity, if the person’s name is not “John”.

{%= notEqualTo(profile.person.name,"John") %}

Regular expression group

The Group function is used to extract specific information, based on the regular expression provided.

Format

{%= regexGroup(STRING, EXPRESSION, GROUP) %}
Argument Description
{STRING} The string to perform the check on.
{EXPRESSION} The regular expression to match against the first string.
{GROUP} Expression group to match against.

Example

The following query is used to extract the domain name from an email address.

{%= regexGroup(emailAddress,"@(\w+)", 1) %}

Replace

The replace function is used to replace a given substring in a string with another substring.

Format

{%= replace(string,string,string) %}

Example

The following function .


Replace All

The replaceAll function is used to replace all substrings of a text that matches the “target” with the specified literal “replacement” 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”.

Format

{%= replaceAll(string,string,string) %}

Right trim

The rightTrim function is used removes white spaces from end of a string.

Format

{%= rightTrim(string) %}

Split

The split function is used to split a string by a given character.

Format

{%= split(string,string) %}

Starts with

The startsWith function is used to determine if a string starts with a specified substring.

Format

{%= startsWith(STRING_1, STRING_2, CASE_SENSITIVE) %}

Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The string to search for within the first string.
{CASE_SENSITIVE} An optional parameter to determine if the check is case sensitive. By default, this is set to true.

Example

The following query determines, with case sensitivity, if the person’s name starts with “Joe”.

{%= startsWith(person.name,"Joe") %}

Title Case

The titleCase function is used to capitalize first letters of each words of a string.

Syntax

{%= titleCase(string) %}

Example

If the person lives in Washington high street, this function will return Washington High Street.

{%= titleCase(profile.person.location.Street) %}

Trim

The trim function removes all white spaces from the beginning and at the end of a string.

Syntax

{%= trim(string) %}

Upper Case

The upperCase function converts a string to upper case letters.

Syntax

{%= upperCase(string) %}

Example

This function converts the profile last name to upper case letters.

{%= upperCase(profile.person.name.lastName) %}

On this page