Using a Regular Expression to Capture a Keyword

When you create a keyword in MEP, one of the keyword options you can select is regular expression. If you're not familiar with regular expressions, these are a way to search text for a pattern you might expect, such as the word help sent in different variations, like hlp, HELP, or Help. Most software developers will be familiar with regular expressions.

You can use regular expressions (regexp) within MEP using the standard Java regexp syntax. Regular expressions are incredibly powerful and complex, and describing the full functionality and syntax of regexp is beyond the scope of this website. However, we do provide a brief overview of common syntax; see Using Regular Expressions in EL.

To use a regular expression to capture a keyword:

  1. Click the Routing tab.
  2. Click the plus icon ()by the routing code to expand a list of the keyword options.
  3. Click Add Keyword.

    The Create Keyword dialog box appears.

  4. Select Regular expression as the type of keyword to create.

    ASMS Regular Expression section appears on the dialog box, allowing you to set the expression.

  5. Enter your regular expression.

    You can enter multiple capture groups; however, in the vast majority of cases you will only want to include one capture group. If you have multiple capture groups, you can choose whether each group is for a keyword or for the message content.

  6. Under Capturing Group make sure that you select the Keyword check box. This ensures that MEP knows that the capture group is for your keyword, and will populate the MEP variables related to keywords with the value sent in by the end user. If you have multiple capture groups, then you must select the Keyword check box or each relevant capture group.
  7. Choose the Service category and service from the drop -down lists.
  8. Click Save.

    Messages that match the keyword will now route to the selected service.

    Create SMS keyword modal showing where to select the keyword setting