Profile Query Language (PQL) offers functions to make interaction with strings simpler. More information about other PQL functions can be found in the Profile Query Language overview.
The like
function is used to determine if a string matches a specified pattern as a boolean.
Format
{STRING_1} like {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 _ .
|
Example
The following PQL query retrieves all the cities containing the pattern “es”.
city like "%es%"
The startsWith
function is used to determine if a string starts with a specified substring as a boolean.
Format
{STRING_1}.startsWith({STRING_2}, {BOOLEAN})
Argument | Description |
---|---|
{STRING_1} |
The string to perform the check on. |
{STRING_2} |
The string to search for within the first string. |
{BOOLEAN} |
An optional parameter to determine if the check is case sensitive. By default, this is set to true. |
Example
The following PQL query determines, with case sensitivity, if the person’s name starts with “Joe”.
person.name.startsWith("Joe")
The doesNotStartWith
function is used to determine if a string does not start with a specified substring as a boolean.
Format
{STRING_1}.doesNotStartWith({STRING_2}, {BOOLEAN})
Argument | Description |
---|---|
{STRING_1} |
The string to perform the check on. |
{STRING_2} |
The string to search for within the first string. |
{BOOLEAN} |
An optional parameter to determine if the check is case sensitive. By default, this is set to true. |
Example
The following PQL query determines, with case sensitivity, if the person’s name does not start with “Joe”.
person.name.doesNotStartWith("Joe")
The endsWith
function is used to determine if a string ends with a specified substring as a boolean.
Format
{STRING_1}.endsWith({STRING_2}, {BOOLEAN})
Argument | Description |
---|---|
{STRING_1} |
The string to perform the check on. |
{STRING_2} |
The string to search for within the first string. |
{BOOLEAN} |
An optional parameter to determine if the check is case sensitive. By default, this is set to true. |
Example
The following PQL query determines, with case sensitivity, if the person’s email address ends with “.com”.
person.emailAddress.endsWith(".com")
The doesNotEndWith
function is used to determine if a string does not end with a specified substring as a boolean.
Format
{STRING_1}.doesNotEndWith({STRING_2}, {BOOLEAN})
Argument | Description |
---|---|
{STRING_1} |
The string to perform the check on. |
{STRING_2} |
The string to search for within the first string. |
{BOOLEAN} |
An optional parameter to determine if the check is case sensitive. By default, this is set to true. |
Example
The following PQL query determines, with case sensitivity, if the person’s email address does not end with “.com”.
person.emailAddress.doesNotEndWith(".com")
The contains
function is used to determine if a string contains a specified substring as a boolean.
Format
{STRING_1}.contains({STRING_2}, {BOOLEAN})
Argument | Description |
---|---|
{STRING_1} |
The string to perform the check on. |
{STRING_2} |
The string to search for within the first string. |
{BOOLEAN} |
An optional parameter to determine if the check is case sensitive. By default, this is set to true. |
Example
The following PQL query determines, with case sensitivity, if the person’s email address contains the string “2010@gm”.
person.emailAddress.contains("2010@gm")
The doesNotContain
function is used to determine if a string does not contain a specified substring as a boolean.
Format
{STRING_1}.doesNotContain({STRING_2}, {BOOLEAN})
Argument | Description |
---|---|
{STRING_1} |
The string to perform the check on. |
{STRING_2} |
The string to search for within the first string. |
{BOOLEAN} |
An optional parameter to determine if the check is case sensitive. By default, this is set to true. |
Example
The following PQL query determines, with case sensitivity, if the person’s email address does not contain the string “2010@gm”.
person.emailAddress.doesNotContain("2010@gm")
The equals
function is used to determine if a string is equal to the specified string as a boolean.
Format
{STRING_1}.equals({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 PQL query determines, with case sensitivity, if the person’s name is “John”.
person.name.equals("John")
The notEqualTo
function is used to determine if a string is not equal to the specified string as a boolean.
Format
{STRING_1}.notEqualTo({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 PQL query determines, with case sensitivity, if the person’s name is not “John”.
person.name.notEqualTo("John")
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 as a boolean.
Format
{STRING_1}.matches(STRING_2})
Example
The following PQL query determines, without being case sensitive, if the person’s name starts with “John”.
person.name.matches("(?i)^John")
If you are using regular expression functions such as \w
, you must escape the backslash character. So, instead of writing just \w
, you must include an extra backslash and write \\w
.
The regexGroup
function is used to extract specific information, based on the regular expression provided as a string.
Format
{STRING}.regexGroup({EXPRESSION})
Example
The following PQL query is used to extract the domain name from an email address.
emailAddress.regexGroup("@(\\w+)", 1)
If you are using regular expression functions such as \w
, you must escape the backslash character. So, instead of writing just \w
, you must include an extra backslash and write \\w
.
Now that you have learned about string functions, you can use them within your PQL queries. For more information about other PQL functions, please read the Profile Query Language overview.