Regular Expression Condition
Use the Regular Expression Condition to make a transition unavailable if a text field input does not match a regular expression. For example, you may want to use this condition to ensure:
- a field contains only letters and numbers. You could use
^[A-Za-z0-9]*$
when you enter the regular expression. - a US Social Security field is populated in the correct format. You could use
^(?!666|000|9\d{2})\d{3}-(?!00)\d{2}-(?!0{4})\d{4}$
when you enter the regular expression. - a UK Postcode field is in the correct format. You could use
^(GIR ?0AA|[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2})$
when you enter the regular expression.
This condition is only available on text fields
Text fields supported include:
- System fields - Description, Environment, and Summary
- Custom fields - Text Field (single line) and Text Field (multi-line)
You can add this condition to any transition in a workflow that allows conditions.
Use this condition
- Go to Administration > Issues > Workflows.
- Select Edit on the workflow you want to add a condition to.
- Select the transition to which you wish to add a condition.
- Under Options, select Conditions.
Select Regular expression condition.
Optional: Enter a description of the condition in Note. This allows you to identify your workflow condition more easily.
Select the Field to validate with the regular expression.
Make sure your selected field is on the screen for the project(s) your condition applies. This condition function will check field values even if they are not on the screen.
Enter the Java Regular Expression to validate the field value against. You can expand Show Examples for common regular expressions.
For a tutorial on how to write a regular expression, see Oracle's Regular Expressions tutorial.
We recommend you test your regular expression before saving.
Optional: Select Match Entire String. When selected, all text input in the chosen field must match the regular expression provided. By default, the condition only checks if the regular expression exists in part of the text field value.
- Enter a Preview Issue Key to test the regular expression on an existing issue.
- Select Preview.
The result will display astrue
orfalse
, depending if the issue provided matches the regular expression or not. - Select Update.
Select Publish and choose if you want to save a backup copy of the workflow.