Jira Automation smart value
indexOf() and lastIndexOf() in Jira Automation
indexOf() gives the position of the first match of a text inside another text, and lastIndexOf() the position of the last match. Both count from 0 and return -1 when the text is not found. You mostly feed the number to substring().
Syntax
{{issue.summary.indexOf("text")}}
{{issue.summary.lastIndexOf("text")}}
Arguments
| Argument | What it is | Required |
|---|---|---|
text | The text to look for. The match is case-sensitive. | yes |
Works on
- Fields: any text value, such as issue.summary or issue.description.
- Returns: a number, the position where the match starts, or -1.
Examples
{{issue.summary.indexOf("Wo")}}Find where the word World starts in Hello World!.
Result:
6Run on Jira Cloud on .
{{issue.summary.indexOf("o")}}First o in the summary.
Result:
4Run on Jira Cloud on .
{{issue.summary.lastIndexOf("o")}}Last o in the summary, for a summary with two of them.
Result:
7Run on Jira Cloud on .
{{issue.summary.toLowerCase().indexOf("world")}}Search without caring about capitals by lowering the text first.
Result:
6Run on Jira Cloud on .
{{issue.description.substring(0, issue.description.indexOf("."))}}Keep only the first sentence of the description, up to the first full stop.
Result:
Checkout page redesignRun on Jira Cloud on .
Where the documentation differs
{{issue.summary.indexOf("ello")}}Run on Jira Cloud, : the documentation says
2, the actual result is1.{{issue.summary.indexOf("d!")}}Run on Jira Cloud, : the documentation says
11, the actual result is10.{{issue.summary.lastIndexOf("wo")}}Run on Jira Cloud, : the documentation says
7, the actual result is-1.{{issue.summary.lastIndexOf("ll")}}Run on Jira Cloud, : the documentation says
4, the actual result is2.{{issue.summary.lastIndexOf("rl")}}Run on Jira Cloud, : the documentation says
9, the actual result is8.
Pitfalls
- Several results on the Atlassian page are off. On
Hello World!the position ofellois 1, not 2, andd!starts at 10, not 11 (checked on Jira Cloud, November 2026). Positions start at 0 and name the first character of the match. - lastIndexOf() also returns the position where the last match starts, not where it ends:
lastIndexOf("ll")gives 2 andlastIndexOf("rl")gives 8. - The search is case-sensitive.
lastIndexOf("wo")andindexOf("world")both give -1 onHello World!; lower the text first if case should not matter. - A second argument for a start position is not accepted:
indexOf("o", 5)renders an empty value, not 7.
Related
- substring()
- substringAfter(), substringBefore(), substringBetween()
- charAt()
- left() and right()
- match()
- split()