String functions
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.
Like
The like
function is used to determine if a string matches a specified pattern as a boolean.
Format
{STRING_1} like {STRING_2}
{STRING_1}
{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 PQL query retrieves all the cities containing the pattern 鈥渆s鈥.
city like "%es%"
Starts with
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})
{STRING_1}
{STRING_2}
{BOOLEAN}
Example
The following PQL query determines, with case sensitivity, if the person鈥檚 name starts with 鈥淛oe鈥.
person.name.startsWith("Joe")
Does not start with
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})
{STRING_1}
{STRING_2}
{BOOLEAN}
Example
The following PQL query determines, with case sensitivity, if the person鈥檚 name does not start with 鈥淛oe鈥.
person.name.doesNotStartWith("Joe")
Ends with
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})
{STRING_1}
{STRING_2}
{BOOLEAN}
Example
The following PQL query determines, with case sensitivity, if the person鈥檚 email address ends with 鈥.com鈥.
person.emailAddress.endsWith(".com")
Does not end with
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})
{STRING_1}
{STRING_2}
{BOOLEAN}
Example
The following PQL query determines, with case sensitivity, if the person鈥檚 email address does not end with 鈥.com鈥.
person.emailAddress.doesNotEndWith(".com")
Contains
The contains
function is used to determine if a string contains a specified substring as a boolean.
Format
{STRING_1}.contains({STRING_2}, {BOOLEAN})
{STRING_1}
{STRING_2}
{BOOLEAN}
Example
The following PQL query determines, with case sensitivity, if the person鈥檚 email address contains the string 鈥2010@gm鈥.
person.emailAddress.contains("2010@gm")
Does not contain
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})
{STRING_1}
{STRING_2}
{BOOLEAN}
Example
The following PQL query determines, with case sensitivity, if the person鈥檚 email address does not contain the string 鈥2010@gm鈥.
person.emailAddress.doesNotContain("2010@gm")
Equals
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})
{STRING_1}
{STRING_2}
Example
The following PQL query determines, with case sensitivity, if the person鈥檚 name is 鈥淛ohn鈥.
person.name.equals("John")
Not equal to
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})
{STRING_1}
{STRING_2}
Example
The following PQL query determines, with case sensitivity, if the person鈥檚 name is not 鈥淛ohn鈥.
person.name.notEqualTo("John")
Matches
The matches
function is used to determine if a string matches a specific regular expression. Please refer to 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鈥檚 name starts with 鈥淛ohn鈥.
person.name.matches("(?i)^John")
\w
, you must escape the backslash character. So, instead of writing just \w
, you must include an extra backslash and write \\w
.Regular expression group
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)
\w
, you must escape the backslash character. So, instead of writing just \w
, you must include an extra backslash and write \\w
.Next steps
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.