Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Teams
, (opens new window)

HTML for Confluence
Results will update as you type.
  • Overview
  • Installation
  • Get started
  • Tutorials
    • Tutorials - Data Center
      • How to render wiki from XML or XSL files
      • How to use regular expressions
      • How to use URLs in macros
    • Tutorials - Cloud
  • Migration
  • Release notes
  • Help and support
  • Miscellaneous
    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    How to use regular expressions
    Updated May 02, 2024

    How to use regular expressions

    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. It is recommended to test your regular expressions in one of the well-known regex testing sites such as RegexPlanet or Regex101.

    • 1 Simple examples
    • 2 Advanced examples
    • 3 References
    • 1 Simple examples
    • 2 Advanced examples
    • 3 References

    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 finds 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.

    • Use the Dotall mode to match across line breaks. 

    Simple examples

    Value

    Regex

    Matches

    Demonstrates

    Value

    Regex

    Matches

    Demonstrates

    ABC

    A.C

    . matches any single character

    ABC

    A.*

    • indicates 0 or more characters

    ABC

    .*C

     

    A.B

    A\.B

    Escape special regex characters with backslash if necessary

    ABC

    AB*

    Regex is NOT generic matching

    ABC

    A.+

    + indicates 1 or more

    ABC

    ABC.+

     

    ABC

    ABC.*

     

    ABCD

    ABC.*

     

    ABC

    [ABCD]

    [ ] indicates a class of characters

    ABC

    [ABZ]

     

    ABC8

    [A-Z0-9]

    • indicates a range of characters

    ABC

    [AB^C]

    ^ in a class means NOT the following character

    ABC

    DEF|ABC

    | indicates OR

    image.png

    .*png|.*jpg

     

    image.jpg

    .*png|.*jpg

     

    image.JPG

    .*png|.*jpg

    defaults to case sensitive matching

    image.JPG

    (?i).*png|.*jpg

    (?i) indicates case insensitive matching

    ABAB

    (AB)+

    () indicates a grouping

    ABCD

    (AB)+

     

    112233

    \d+

    \d for digits

    A B

    A\s*B

    \s for whitespace

    ABC

    \S*

    \S for non whitespace

     

    \S+

    Value must have at least 1 non whitespace character

    A

    \S+

     

    XYZ,ABC,UVW

    .*\bABC\b.*

    Word boundaries. Finding words in a comma or blank separated list using word boundaries

    XYZ,ABCD,UVW

    .*\bABC\b.*

     

    ABC

    (?m)(^ABC$)|(^ABC,)|(,ABC,)|(,ABC$)

    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$)

     

    XYZ,ABC DEF,UVW

    (?m)(^ABC$)|(^ABC,)|(,ABC,)|(,ABC$)

     

    Advanced examples

    Value

    Regex

    Matches

    Find

    Demonstrates

    Value

    Regex

    Matches

    Find

    Demonstrates

    example.txt

    ^((?!\.png).)*$

    Find string not containing a word. In this example, files that do not have a .png extension

    example.png

    ^((?!\.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 both collateral and retail must be included for 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

    • Page:
      How to implement regex pattern for attachments that exclude either of two labels using Advanced Tables for Confluence (One Appfire Support Knowledge Base)
    • Page:
      How to condition the creation of issues (One Appfire Support Knowledge Base)
    • Page:
      How to condition issue creation (One Appfire Support Knowledge Base)
    • Page:
      How to add condition to a blank or empty field (One Appfire Support Knowledge Base)
    • Page:
      Use regex to remove Include macro from space(s) using Confluence CLI (One Appfire Support Knowledge Base)
    • Page:
      How to remove specific word(s) on a page using the Confluence CLI findReplaceRegex parameter (One Appfire Support Knowledge Base)
    • Page:
      How to add regular expression check validator for IP address and host name (One Appfire Support Knowledge Base)
    • Page:
      How to validate input values in the text field that are separated by comma with regular expression (One Appfire Support Knowledge Base)
    • Page:
      How to assign issue automatically based on Email Keywords (One Appfire Support Knowledge Base)
    • Page:
      Define condition based issue creation (Create on Transition for Jira)
    • Page:
      Add condition to a blank or an empty field (Create on Transition for Jira)
    • Page:
      Define condition based issue creation - Cloud (Create on Transition for Jira)
    • Page:
      matchStart (Power Scripts for Jira Cloud) — Returns the position where the match starts or -1 if it doesn't match.
    • Page:
      matchReplace (Power Scripts for Jira Cloud) — Uses a regex expression to find and replace text within a string.
    • Page:
      matchEnd (Power Scripts for Jira Cloud) — Returns the position where the match ends or -1 if it doesn't match.

    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?

     

    Need support? Create a request with our support team.

    Copyright © 2005 - 2025 Appfire | All rights reserved.

    {"serverDuration": 14, "requestCorrelationId": "90814a39c8874a5c90c228287fdb98e8"}