---
title: "How to use regular expressions"
canonical: "https://support.appfire.com/space/HTML/70615332/How%20to%20use%20regular%20expressions"
format: markdown
---
> Macro (aura-html)

<span style="color: #000000">A number of apps provide advanced features that require the use of</span> [regular expressions](http://en.wikipedia.org/wiki/Regular_expression) <span style="color: #000000">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. It is recommended to test your regular expressions in one of the well-known regex testing sites such as</span> [RegexPlanet](http://www.regexplanet.com/advanced/java/index.html) <span style="color: #000000">or</span> [Regex101](https://regex101.com/)<span style="color: #000000">.</span>

> ℹ️ *Regex for workflow conditions*
> ℹ️ 
> ℹ️ <span style="color: #000000">For Jira workflow functions using regex expressions to condition whether the post function should continue processing, a </span><span style="color: #000000">*blank*</span><span style="color: #000000"> pattern means that condition processing is not done and processing should continue.</span>

> ✅ *Key tips*
> ✅ 
> ✅ - <span style="color: #000000">Dot or period (.) is a special regex character. If you really want to match on it, you need to escape it with a backslash: </span><span style="color: #000000">**\**</span><span style="color: #000000">.</span>
> ✅ - <span style="color: #000000">Don't be confused with generic pattern matching used for file systems for instance. On a file system, </span>`*.png`<span style="color: #000000"> means all files ending with </span>`.png`<span style="color: #000000">. That is an illegal regex expression. For regex you need: </span>`.*\.png`<span style="color: #000000">, or to simplify: </span>`.*png`<span style="color: #000000"> which finds all files ending in </span>`png`<span style="color: #000000"> (not necessarily ending in an extension of PNG).</span>
> ✅ - <span style="color: #000000">Regex is </span><span style="color: #000000">*case sensitive*</span><span style="color: #000000"> by default. In most cases, use the case insensitive flag: </span><span style="color: #000000">*(?i)*</span><span style="color: #000000">. See one of the examples below.</span>
> ✅ - <span style="color: #000000">Use the </span><span style="color: #000000">**Dotall**</span><span style="color: #000000"> mode to match across line breaks. </span>
> ✅ 
> ✅ > Macro (legacy-content)

## <span style="color: #000000">Simple examples</span>

| **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: |  |

## <span style="color: #000000">Advanced examples</span>

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

> Macro (contentbylabel)

## References

- [RegexOne](http://regexone.com/) <span style="color: #000000">- interactive tutorials to learn how to construct regular expressions</span>
- [Regexlib.com](http://regexlib.com/) <span style="color: #000000">- searchable collection of user-contributed regular expressions</span>
- [RegexPlanet test site](http://www.regexplanet.com/advanced/java/index.html) <span style="color: #000000">- test your expressions quickly</span>
- [Regex101 test site](https://regex101.com/) <span style="color: #000000">- understand a regex expression and test it</span>
- [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)<span style="color: #000000">- best once you have the concepts</span>
- [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)