MATCHES

Description

Returns TRUE if the provided string matches any of the specified regular expressions; otherwise, returns FALSE.

Syntax

MATCHES(string, ...regex_expressions) -> Boolean

Parameters

ParameterData TypeRequiredDescription
stringStringYesThe text to evaluate against the provided regular expressions.
…regex_expressionsStringYesOne or more regular expressions to test against the string.

Examples

MATCHES("123-456-7890", 
        "^\d{3}-\d{3}-\d{4}$",
        "^\(\d{3}\) \d{3}-\d{4}$")
-- Returns TRUE because the string matches the first pattern.
MATCHES("user@example.com",
        "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$")
-- Returns TRUE.

Tips

  • Regular expressions must follow Apex or Java syntax.