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) %}

Get url host

The getUrlHost function is used to retrieve the hostname of a URL.

Format

{%= getUrlHost(string) %}: string

Example

{%= getUrlHost("http://www.myurl.com/contact") %}

Returns “www.myurl.com”

Get url path

The getUrlPath function is used to retrieve the path after the domain name of a URL.

Format

{%= getUrlPath(string) %}: string

Example

{%= getUrlPath("http://www.myurl.com/contact.html") %}

Returns “/contact.html”

Get url protocol

The getUrlProtocol function is used to retrieve the protocol of a URL.

Format

{%= getUrlProtocol(string) %}: string

Example

{%= getUrlProtocol("http://www.myurl.com/contact.html") %}

Returns “http”

Index Of

The indexOf function is used to return the position (in the first argument) of the first occurrence of the second parameter. Returns -1 if there is no match.

Format

{%= indexOf(STRING_1, STRING_2) %}: integer
Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The string to search in the first parameter

Example

{%= indexOf("hello world","world" ) %}

Returns 6.

Is empty

The isEmpty function is used to determine if 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) %}

Is Not Empty

The isNotEmpty function is used to determine if a string is not empty.

Format

{= isNotEmpty(string) %}: boolean

Example

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

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

Last Index Of

The lastIndexOf function is used to return the position (in the first argument) of the last occurrence of the second parameter. Returns -1 if there is no match.

Format

{= lastIndexOf(STRING_1, STRING_2) %}: integer
Argument Description
{STRING_1} The string to perform the check on.
{STRING_2} The string to search in the first parameter

Example

{%= lastIndexOf("hello world","o" ) %}

Returns 7.

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") %}

Mask (#mask)

The Mask function is used to replace a part of a string with “X” characters.

Format

{%= mask(string,integer,integer) %}

Example

The following query replaces the “123456789” string with “X” characters, excepted for the first and the last 2 characters.

{%= mask("123456789",1,2) %}

The query returns 1XXXXXX89.

MD5

The md5 function is used to calculate and return the md5 hash of a string.

Format

{%= md5(string) %}: string

Example

{%= md5("hello world") %}

Returns “5eb63bbbe01eeed093cb22bb8f5acdc3”

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") %}

Not Equal With Ignore Case

The notEqualWithIgnoreCase function is used to compare two strings ignoring case.

Format

{= notEqualWithIgnoreCase(STRING_1,STRING_2) %}: boolean
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 if the person’s name is not “john”, with no case sensitivity.

{%= 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_1,STRING_2,STRING_3) %}:string
Argument Description
{STRING_1} The string where the substring must be replaced.
{STRING_2} The substring to replace.
{STRING_3} The replacement substring.

Example

{%= replace("Hello John, here is your monthly newsletter!","John","Mark") %}

Returns “Hello Mark, here is your monthly newsletter!”

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") %}

String to integer

The string_to_integer function is used to convert a string value into an integer value.

Format

{= string_to_integer(string) %}: int

String to number

The stringToNumber function is used to convert a string into number. It returns the same string as output for invalid input.

Format

{%= stringToNumber(string) %}: double

Sub string

The Count string function is used to return the sub-string of the string expression between the begin index and the end index.
Format

{= substr(string, integer, integer) %}: string

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) %}

To Bool

The toBool function is used to convert an argument value into a boolean value, depending on its type.

Format

{= toBool(string) %}: boolean

To Date Time

The toDateTime function is used to convert string to date. It returns the epoch date as output for invalid input.

Format

{%= toDateTime(string, string) %}: date-time

To Date Time Only

The toDateTimeOnly function is used to convert an argument value into a date time only value… It returns the epoch date as output for invalid input.

Format

{%= toDateTimeOnly(string) %}: date-time

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) %}

url decode

The urlDecode function is used to decode a url encoded string.

Format

{%= urlDecode(string) %}: string

Url encode

The Count only null function is used to url encode a string.

Format

{%= urlEncode(string) %}: string

On this page