How to use regular expressions - Cloud
Overview
A number of apps provide advanced features that require the use of regular expressions 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 or Regex101.
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
Advanced examples
Value | Regex | Matches | Find | Demonstrates |
---|---|---|---|---|
example.txt |
| Find string not containing a word. In this example, files that do not have a .png extension | ||
example.png |
| Find string not containing a word. In this example, files that do not have a .png extension | ||
example.jpeg | (?=^((?!\.png).)*$)(?=^((?!\.jpeg).)*$) | 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.*).* | 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.*).* | Both are required for a match | ||
merger acquisition | .*\b(?:merger|acquisition)\b.* | Match string containing either word |
Content with regex label
-
How to implement regex pattern for attachments that exclude either of two labels using Advanced Tables for Confluence (One Appfire Support Knowledge Base)
-
How to condition the creation of issues (One Appfire Support Knowledge Base)
-
How to condition issue creation (One Appfire Support Knowledge Base)
-
How to add condition to a blank or empty field (One Appfire Support Knowledge Base)
-
Use regex to remove Include macro from space(s) using Confluence CLI (One Appfire Support Knowledge Base)
-
How to remove specific word(s) on a page using the Confluence CLI findReplaceRegex parameter (One Appfire Support Knowledge Base)
-
How to use regular expressions (Information)
-
How to add regular expression check validator for IP address and host name (One Appfire Support Knowledge Base)
-
How to validate input values in the text field that are separated by comma with regular expression (One Appfire Support Knowledge Base)
-
How to assign issue automatically based on Email Keywords (One Appfire Support Knowledge Base)
-
How to use pattern matching conditioning (Update on Transition for Jira)
-
Define condition based issue creation (Create on Transition for Jira)
-
Add condition to a blank or an empty field (Create on Transition for Jira)
-
How to condition the creation of issues (Create on Transition for Jira)
-
How to condition on a field being blank or empty (Create on Transition for Jira)
References
- RegexOne - interactive tutorials to learn how to construct regular expressions
- Regexlib.com - searchable collection of user-contributed regular expressions
- RegexPlanet test site - test your expressions quickly
- Regex101 test site - understand a regex expression and test it
- Wikipedia regular expressions
- Regular expression reference
- Quick reference - best once you have the concepts
- Using word boundaries
- Regular expression to match string not containing a word?
Log a request with our support team.
Confluence®, Jira®, Atlassian Bamboo®, Bitbucket®, Fisheye®, and Atlassian Crucible® are registered trademarks of Atlassian®
Copyright © 2005 - 2024 Appfire | All rights reserved. Appfire™, the 'Apps for makers™' slogan and Bob Swift Atlassian Apps™ are all trademarks of Appfire Technologies, LLC.