Escape a Metacharacter

To use the literal meaning of a Java RegEx metacharacter in a regular expression, you must cancel the metacharacter, which is called escaping. You can escape a metacharacter in two ways.

Required Editions

User Permissions Needed
To escape special Java characters Admin
  1. Add a double backslash (\\) before the metacharacter. In this example, the double backslash is used to escape the ? metacharacter to reference it as a delimiter.
    escaping method example
  2. Enclose the metacharacter within \Q and \E. In this example,\Q and \E are used to escape the | metacharacter to reference it as a delimiter.
    Escaping example 2
  3. These commonly used metacharacters require escaping to be referenced literally in a regex:
    < ( [ { \ ^ - = $ ! | ] } ) ? * + . > _
  4. These functions in Marketing Cloud Intelligence contain delimiters as part of their syntax.
    SPLIT(text,delimiter) Use the SPLIT function where a ‘|’ character is the delimiter:
    SPLIT([Media_Buy_Name],'\\Q|\\E')
    SELECT(sourceStr,pattern) Use the SELECT function where a ‘>’ character is the delimiter:
    SELECT([Media_Buy_Name],'\\>(.*?)E')