# match() in Jira Automation: syntax and examples

URL: https://goingstellar.ro/reference/smart-values/match/

match() runs a regular expression against a text value and returns what the first capture group caught. It is the tool for pulling a build number, a keyword argument or an identifier out of a summary, description or comment.

## Syntax

```
{{issue.summary.match("regular expression with (a group)")}}
```

## Arguments

- `regular expression` (required: yes): Java regular expression. The part in round brackets is the group that is returned.

## Works on

- Fields: any text value
- Returns: the text of the first group; a list when the expression matches several times; empty when nothing matches

## Examples

```
{{issue.summary.match(".*(lo).*")}}
```

Returns the characters caught by the group, which is lo in Hello World!.

Result:

```
lo
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.comments.last.body.match(".*build (\d+).*")}}
```

Reads the build number out of the latest comment. With a comment reading Second comment: fixed in build 42 the result is the number alone.

Result:

```
42
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.description.match("Customer (\w+)")}}
```

Takes the word that follows a keyword in the description, without having to match the whole text.

Result:

```
reported
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.summary.match("(?i).*(world).*")}}
```

The (?i) flag ignores case, and the group returns the text as it is written in the summary.

Result:

```
World
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.summary.match("(o)")}}
```

Without leading and trailing wildcards, the expression is searched for repeatedly. Both o characters come back as a list.

Result:

```
o, o
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.summary.match(".*(xyz).*")}}
```

When nothing matches the result is empty, so a later step can test for that.

Run on Jira Cloud on 29 Nov 2026.

## Where the documentation differs

- `{{issue.summary.match(".*(o).*")}}`: run on Jira Cloud, 29 Nov 2026: the documentation says `[o, o]`, the actual result is `o`.

## Pitfalls

- A group is required. `match("Hello")` has no round brackets and gave an empty result, even though the text contains Hello (checked on Jira Cloud, November 2026).
- Whether you get one value or a list depends on the expression. `.*(o).*` matches the whole text once and gave a single o, while `(o)` matched twice and gave a list. Atlassian's page shows `[o, o]` for the first form, which is not what Jira returned (checked on Jira Cloud, November 2026).
- Only the first group is returned. `(\w+) (\w+)` on Hello World! gave Hello, so use separate calls or a different expression when you need the second word.
- Calling `.first` on a single match gave an empty result (checked on Jira Cloud, November 2026). Use `.first` only when the result is a list.

## Questions and answers

### How do I search for text that contains regular expression characters?

Wrap it with `quote()`, which escapes the whole value as a literal. The output starts with \Q and ends with \E.

## Related

- [replace(), replaceAll() and remove()](https://goingstellar.ro/reference/smart-values/replace/)
- [split()](https://goingstellar.ro/reference/smart-values/split/)
- [substringAfter(), substringBefore(), substringBetween()](https://goingstellar.ro/reference/smart-values/substringafter-substringbefore/)
- [isEmpty() and isNotEmpty()](https://goingstellar.ro/reference/smart-values/isempty-isnotempty/)
- [htmlEncode, xmlEncode, jsonEncode and quote()](https://goingstellar.ro/reference/smart-values/htmlencode-xmlencode-jsonencode/)

## Sources

- [Jira smart values: text fields (Atlassian Support)](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/)

