The function ecm:regexMatches determines whether a specified value matches a given regular expression. The value returned is a Boolean data type.

Example

A message is customized for recipients with email addresses from Yahoo, Gmail, or Hotmail. A line of text is inserted into the message using an ​InsertIf​ statement, which is structured as follows:

A message is customized for recipients with email addresses from Yahoo, Gmail, or Hotmail, including country-specific domains like ​yahoo.de​. A line of text is inserted into the message using an InsertIf statement, which is structured as follows:

<%InsertIf expression="${ecm:regexMatches(user['Email'],'.+@(yahoo|gmail|hotmail)\..+')}"%>Text<%/InsertIf%>
CODE

The characters included in the regular expression define the query as follows:

  • The period (​.​) indicates that a single character exists in the queried element which does not have to match the regular expression.

  • The plus sign (​+​) indicates that there are one or more of the preceding elements (a single character). This means that anything that appears before the @ sign in the email address is returned.

  • The parenthesis ​()​ define the subexpression, in this case, the three email domains.

  • The vertical bar (​|​) separates alternative items included in the query.

  • The backslash (​\​) escapes the expression to show that the character that follows (the period) is a regular character to include in the query.

  • The combination of a period and plus sign (​.+​) is repeated to indicate that one or more characters exist that do not have to match the regular expression

The whole regular expression must match to be true. For example, if you want to check if an email contains AOL, you must include variables that take into account any characters that could appear before or after AOL in the target string.

Structure​

ecm:regexMatches(string, string)

Parameters​

Parameter

Description

string

Specifies the target string that is queried against the regular expression.

string

The regular expression, in single quotes. The regular expression defines how the query is performed (see http://en.wikipedia.org/wiki/Regex).