Work With RegEx
  • 09 Sep 2022
  • 1 Minute To Read
  • PDF

Work With RegEx

  • PDF

Tip - Consider using Words instead of RegEx
Words is another text-matching Condition method that doesn't require technical knowledge to understand and implement. In many cases, Words can replace RegEx. For example, suppose you're attempting to route Spanish language requests to a Spanish Inbox which usually contains the words "Gracias," "Hola," and "Orden." Using Words can detect and route those requests to your Spanish Inbox without needing RegEx.

Regular Expressions (RegEx) are used to extract information from text by searching for matches of a specific search pattern. In Rules and People Match Boosts, RegEx is helpful in distinguishing words that could be part of other words. This is particularly useful to distinguish words that can be part of other words, like "ask" to match phrases that may have variable text.

Using ask as an example, ask is contained in basketball and task, but sometimes, you may only want a Rule or boost to fire if the Customer says "can I ask you something" and not fire if they say "I want to buy a gift basket.

RegEx is a popular method for detecting spam inbound communications via Rules (by detecting specific spam keywords in an email), applying spam Topic, and closing the Conversation so Agents are not bothered by spam communications. RegEx matching in Gladly uses Google's re2 library.

Note - Work with a Developer to use RegEx
RegEx by nature can be complex and require a bit of technical adeptness. While you have resources listed on this page to help you understand and create RegEx, we highly recommend working with a developer to build RegEx.

RegEx syntax

Before you begin using RegEx, it's essential to have basic knowledge of RegEx syntax. Read this tutorial to get familiar with basic RegEx symbols and characters and how they're used to create regular expressions.

You can also complete a free Regex 101 eLearning course to help you become more comfortable using Regex.

RegEx examples

Once you have a basic understanding of Regex syntax, review examples of regular expressions with practical and common usage examples of RegEx syntax.

For example, the image below shows RegEx (?i)(\W|^)(baloney|darn|drat|fooey|gosh\sdarnit|heck)(\W|$) is used to match any word or phrase containing the words "baloney, darn, drat, fooey, gosh darnit, and heck."

Sample RegEx

 RegEx tools

You can validate RegEx before saving them for use in Rules or People Match Boosts by using tools like Rubular to test expressions as you write them.

Was this article helpful?