Going Stellar

Home/Smart values reference

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

ArgumentWhat it isRequired
textThe 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:

6

Run on Jira Cloud on .

{{issue.summary.indexOf("o")}}

First o in the summary.

Result:

4

Run on Jira Cloud on .

{{issue.summary.lastIndexOf("o")}}

Last o in the summary, for a summary with two of them.

Result:

7

Run on Jira Cloud on .

{{issue.summary.toLowerCase().indexOf("world")}}

Search without caring about capitals by lowering the text first.

Result:

6

Run 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 redesign

Run on Jira Cloud on .

Where the documentation differs

  • {{issue.summary.indexOf("ello")}}

    Run on Jira Cloud, : the documentation says 2, the actual result is 1.

  • {{issue.summary.indexOf("d!")}}

    Run on Jira Cloud, : the documentation says 11, the actual result is 10.

  • {{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 is 2.

  • {{issue.summary.lastIndexOf("rl")}}

    Run on Jira Cloud, : the documentation says 9, the actual result is 8.

Pitfalls

  • Several results on the Atlassian page are off. On Hello World! the position of ello is 1, not 2, and d! 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 and lastIndexOf("rl") gives 8.
  • The search is case-sensitive. lastIndexOf("wo") and indexOf("world") both give -1 on Hello 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.

Sources

  1. Jira smart values: text fields (Atlassian Support)

Markdown version · All smart values