Error formatting macro: appfire-confluence-analytics: java.lang.NullPointerException: Cannot invoke "com.atlassian.confluence.xhtml.api.MacroDefinition.getMacroId()" because "macroDefinition" is null
Skip to end of banner
Go to start of banner

How to use pattern matching conditioning

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Description

The regular expression based pattern matching conditioning is a powerful way to do workflow automation by giving the workflow designer a way to control whether actions should be done or not based on the issues related to the transition.

Pattern matching conditioning

This takes advantage of the Substitution variables to provide a very flexible way to condition based on matching issue information with a regular expression (regex). This may be a little bit more complex/less usable for simple cases, but can be very powerful for covering many use cases. The simple cases can still be done with little knowledge of regular expressions. All the standard Substitution variables can be used.

Regex qualifiers

Qualifiers are used to make is easier to construct a regex pattern that matchers the user scenario.

Exact

When looking for patterns, one can either find something that matches the pattern or you can do an exact match on the pattern. Doing find is usually easier and covers most use cases, but is not as precise as doing an exact match. The default is Find. Select the Exact checkbox if needed to be more precise. 

ValuePatternFindExact Match
abcabc(tick)(tick)
abcab(tick)(error)
abcac(error)(error)
abcb(tick)(error)
abc.*b.*(tick)(tick)

Literal

Regex has various characters that have special meaning. These characters need to be escaped (using \) if you want the character to not have special meaning. In some cases, you want to ignore all special character meaning and match on the literal string. Use the Literal checkbox to treat the pattern as a literal string.

ValuePatternNormalLiteral
abc.bc(tick)(error)
.bc.bc(tick)(tick)
abcabc*(tick)(error)
ababc*(tick)(error)
ababc+(error)(error)

Negative

Regex can be difficult when you want to condition on something not matching. The Negative checkbox makes it easy to reverse the condition so that the condition is true if the match is false and vice versa.

ValuePatternNormalReverseNotes
abcabc(tick)(error) 
xyzabc(error)(tick) 
 \S+(error)(tick)Use Exact to make sure there is no match on a value containing a blank with other characters

Case sensitivity

Regex patterns, by default, are case sensitive. Use the embedded flag (?i) to get case insensitive matching.

ValuePatternNormal
ABCabc(error)
ABC(?i)abc(tick)

Or conditions

ValuePatternNormalNotes
aa|b(tick) 
ba|b(tick) 
abc(abc)|(xyx)(tick)Use ( ) or (?: ) for grouping

 

 

Tips

What if I don't need conditions?

Just leave blank (default).

Regex references

Watch out for regex reserved characters

Unless you use literal, you need to be sure any regex reserved characters you use are intentional.

Examples: * + ( ) { } |

Test your regex interactively before you implement your workflow conditions using one of the regex testing websites like: RegexPlanet.

Conditions must both be met

If more than one condition is specified, both must be satisfied (the conditions are anded). Most OR conditions can be done through a single (more complex) regex pattern. See the tip below.

What if I have more than 2 conditions?

Regex patterns can be constructed to handle many situations that involve multiple comparisons.

Example

ValueRegex
Priority: %original_priority%, Status: %original_status%Priority: (Blocker|Critical|Major), Status: (Open|In Progress)

RegexPlanet results

  • No labels