How to Use Regular Expressions Within Automations

Document created by on Feb 20, 2017Last modified by on Feb 20, 2017
Version 2Show Document
  • View in full screen mode

A regular expression (regex for short) is a special text string for describing a search pattern. You can think of regular expressions as commonly used wildcard, but more advanced. You are probably familiar with wildcard notations such as *.txt to find all text files in a file manager. The regex equivalent to *.txt is:  ^.*\.txt$.  That looks (and is) a lot more complex than a simple asterisk, but even though it is complex, it is much more powerful than a simple wildcard.  Don’t worry though, you can easily take advantage of regex in Samanage without being an regex expert.  There are a few basic elements that once you understand, will allow you to create keyword searches that go beyond a single keyword.  In this quick start tutorial we will walk you through a couple of those useful regex examples that will provide you with a powerful way to extend the capabilities of the condition: keyword within the automations feature in Samanage


This quick start tutorial gets you up to speed quickly with regular expressions. Obviously, this brief introduction cannot explain everything there is to know about regular expressions. For more detailed information, consult this website.


Regular Expressions are a useful way to extend the functionality of the keyword condition in Automations, allowing you to includ  e multiple keywords, a variety of spellings, uppercase vs. lowercase letters, and more.  Below are some helpful tips to assist you in getting the most out of this function.


The first concept to understand is how to create a regex to allow for uppercase and lowercase letters to be considered valid by the system.  To do this, you must follow the syntax below:


[kK]eyword  or



Note that the first letter is shown in brackets is in both lowercase and uppercase format.  This will allow for both: keyword, and Keyword to be recognized. 


Now that you understand how to adjust for capitalization, now let’s work on multiple keywords within one condition.  To do that, we will need to create a list.  A list in regex is done via the following syntax:




Note that the | works as an ‘or’ in this list.  In this example any one (or more) of the following keywords would trigger the action associated with this automation: keyword, example, list, or complete.


Now, let’s add those two concepts together; a list with both uppercase and lowercase letters.




This would allow for the following words to be triggers for the automation: urgent, critical, help please, Help Please, help Please, Help please and serious.  Take note the addition of the \s in the keyword ‘Help Please’.  That \s is the regex code for a space.  If the keyword you are looking for has a space in it, you must use \s in place of the space.


The final topic in this introductory tutorial is how to adjust for incorrect, or alternate spellings of words.  To handle this you use the same syntax you would use for uppercase and lowercase letters.  For example if you wanted to account for a common misspelled word such as “consensus” you could use the following:




This would recognize the following words as the keyword, and thus trigger the action you set for this automation:






As you can see, placing letters inside of the brackets [ ] allows for regex to recognize either letter as an option within that keyword.  This can be very helpful when dealing with commonly misspelled words.


If you would like to investigate more ways to use regex, please check out the document found at the following link.  While this document isn’t directed at the Samanage customer, it does detail the different capabilities of regex, which is fully supported within this feature.


We hope that this tutorial is helpful.  As you begin to use regex in Samanage, we ask that you share examples of how you have made it work in your business with the community here. The wisdom of the community is an extremely valuable way for our users to learn how to use the latest features.  So, please share examples and ask questions of each other - we look forward to hearing from you.


Your Samanage team.

4 people found this helpful