indexOf starting at a position

Steve Tedeschi February 8, 2025

Trying to parse user provided content in a table - example

||Property||Value||
|prop1|Value 1|

|prop2|value 2|

eg

||Property||Value||

|Date|2025-02-08|

|Day|Saturday|

|Year|2025|

|Month|February|

|Day|8|

I can use the indexOf to find the property "cells" looking for a way to find the first pipe "|" after "|prop1|"... the first pipe after "|prop2|" etc.

 

1 answer

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 8, 2025

Hi @Steve Tedeschi 

Where are you trying to do this?

For example, if this is with an automation rule you could try using the match() function with a regular expression:

https://confluence.atlassian.com/automation/jira-smart-values-text-fields-993924863.html#Jirasmartvaluestextfields-matchmatch() 

Kind regards,
Bill

Steve Tedeschi February 10, 2025

Thanks for the suggestion - looks promising. Will give it a try and update here.

Steve Tedeschi February 12, 2025

@Bill Sheboy Can you help with syntax to access the array elements? I thought I would add the array index in brackets (e.g., [0]), but am getting the following error:

Error rendering smart-values when executing this rule:

Failed to get value for issue.description.match(".*(|).*")[0]: {{issue.description.match(".*(|).*")[0]}}
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 12, 2025

Hi @Steve Tedeschi 

For accessing list elements in a rule, use the 0-based get() function:

{{issue.description.match(".*(|).*").get(0)}}

or use the first function to get the 0th one:

{{issue.description.match(".*(|).*").first}}

 

Wouldn't both of those just return the pipe character?

Suggest an answer

Log in or Sign up to answer