---
title: "_HowToUseRegularExpressions"
canonical: "https://support.appfire.com/space/TBL/2459402309/_HowToUseRegularExpressions"
format: markdown
---
# Overview

A number of apps provide advanced features that require the use of [regular expressions](http://en.wikipedia.org/wiki/Regular_expression) for pattern matching. Generally, just a simple understanding of regular expressions and a few examples are enough to get by for most use cases. This page has **a few simple examples** to get started. Use the references for more advanced information. We recommend testing your regular expressions in one of the well-known regex testing sites such as [RegexPlanet](http://www.regexplanet.com/advanced/java/index.html) or [Regex101](https://regex101.com/).

> ℹ️ ### Regex for workflow conditions
> ℹ️ 
> ℹ️ For Jira workflow functions using regex expressions to condition whether the post function should continue processing, a **blank** pattern means that condition processing is not done and processing should continue.

> ✅ ### Key tips
> ✅ 
> ✅ - Dot or period (.) is a special regex character. If you really want to match on it, you need to escape it with a backslash: **\.**
> ✅ - Don't be confused with generic pattern matching used for file systems for instance. On a file system, *.png means all files ending with **.png**. That is an illegal regex expression. For regex you need: **.*\.png**. Or to simplify: **.*png** which will find all files ending in **png** (not necessarily ending in an extension of png).
> ✅ - Regex is **case sensitive** by default. In most cases, use the case insensitive flag: **(?i)**. See one of the examples below.
> ✅ - **Dotall** mode when you need to match across line breaks.
> ✅   - In dotall mode, the expression . matches any character, including a line terminator. By default this expression does not match line terminators. Dotall mode can also be enabled via the embedded flag expression **(?s)**. (The s is a mnemonic for "single-line" mode, which is what this is called in Perl.)

# Simple examples

| **Value** | **Regex** | **Matches** | **Demonstrates** |
| --- | --- | --- | --- |
| ABC | A.C | :check_mark: | . matches any single character |
| ABC | A.* | :check_mark: | - indicates 0 or more characters |
| ABC | .*C | :check_mark: |  |
| A.B | A\.B | :check_mark: | Escape special regex characters with backslash if necessary |
| ABC | AB* | :cross_mark: | Regex is NOT generic matching 🙂 |
| ABC | A.+ | :check_mark: | + indicates 1 or more |
| ABC | ABC.+ | :cross_mark: |  |
| ABC | ABC.* | :check_mark: |  |
| ABCD | ABC.* | :check_mark: |  |
| ABC | [ABCD]* | :check_mark: | [ ] indicates a class of characters |
| ABC | [ABZ] | :cross_mark: |  |
| ABC8 | [A-Z0-9] | :check_mark: | - indicates a range of characters |
| ABC | [AB^C] | :cross_mark: | ^ in a class means NOT the following character |
| ABC | DEF|ABC | :check_mark: | | indicates OR |
| image.png | .*png|.*jpg | :check_mark: |  |
| image.jpg | .*png|.*jpg | :check_mark: |  |
| image.JPG | .*png|.*jpg | :cross_mark: | defaults to case sensitive matching |
| image.JPG | (?i).*png|.*jpg | :check_mark: | (?i) indicates case insensitive matching |
| ABAB | (AB)+ | :check_mark: | () indicates a grouping |
| ABCD | (AB)+ | :cross_mark: |  |
| 112233 | \d+ | :check_mark: | \d for digits |
| A B | A\s*B | :check_mark: | \s for whitespace |
| ABC | \S* | :check_mark: | \S for non whitespace |
|  | \S+ | :cross_mark: | Value must have at least 1 non whitespace character |
| A | \S+ | :check_mark: |  |
| XYZ,ABC,UVW | .*\bABC\b.* | :check_mark: | Word boundaries. Finding words in a comma or blank separated list [using word boundaries](http://www.regular-expressions.info/wordboundaries.html) |
| XYZ,ABCD,UVW | .*\bABC\b.* | :cross_mark: |  |
| ABC | (?m)(^ABC$)|(^ABC,)|(,ABC,)|(,ABC$) | :check_mark: | Looking for text matches in a comma separated list by covering all cases: only, start, middle, and end. This uses the multi-line flag: (?m) |
| XYZ,ABC,UVW | (?m)(^ABC$)|(^ABC,)|(,ABC,)|(,ABC$) | :check_mark: |  |
| XYZ,ABC DEF,UVW | (?m)(^ABC$)|(^ABC,)|(,ABC,)|(,ABC$) | :cross_mark: |  |

# Advanced examples

| **Value** | **Regex** | **Matches** | **Find** | **Demonstrates** |
| --- | --- | --- | --- | --- |
| example.txt | `^((?!\.png).)*$` | :cross_mark: | :check_mark: | Find string **not** containing a word. In this example, files that do not have a **.png **extension |
| example.png | `^((?!\.png).)*$` | :cross_mark: | :cross_mark: | Find string **not** containing a word. In this example, files that do not have a **.png **extension |
| example.jpeg | `(?=^((?!\.png).)*$)(?=^((?!\.jpeg).)*$)` | :cross_mark: | :cross_mark: | Find string **not** containing a word. In this example, files that do not have a **.png **or** .jpeg **extension |
| collateral wholesale retail | `.*(?=.*\bretail\b.*)(?=.*\bcollateral\b.*).*` | :check_mark: |  | Match exact words anywhere in string. In this case a blank separated list of labels and we require both collateral and retail to be included before we want the match to be successful |
| wholesale retail | `.*(?=.*\bretail\b.*)(?=.*\bcollateral\b.*).*` | :cross_mark: |  | Both are required for a match |
| merger acquisition | `.*\b(?:merger|acquisition)\b.*` | :check_mark: |  | Match string containing either word |

> Macro (contentbylabel)

# References

- [RegexOne](http://regexone.com/) - interactive tutorials to learn how to construct regular expressions
- [Regexlib.com](http://regexlib.com/) - searchable collection of user-contributed regular expressions
- [RegexPlanet test site](http://www.regexplanet.com/advanced/java/index.html) - test your expressions quickly
- [Regex101 test site](https://regex101.com/) - understand a regex expression and test it
- [Wikipedia regular expressions](http://en.wikipedia.org/wiki/Regular_expression)
- [Regular expression reference](http://www.regular-expressions.info/reference.html)
- [Quick reference ](http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#sum)- best once you have the concepts
- [Using word boundaries](http://www.regular-expressions.info/wordboundaries.html)
- [Regular expression to match string not containing a word?](http://stackoverflow.com/questions/406230/regular-expression-to-match-string-not-containing-a-word)