How to dividing variable into two parts

Ari Raatikainen
Contributor
July 25, 2024

Let's assume the variable {{example}} outputs the values 'KEY-1, KEY-2, KEY-3, KEY-4'. This variable is created to store object keys from lookupObjects.

Using the split function or other text string functions, how can we split the content of the variable {{example}} in half so that the first part {{part1}} outputs 'KEY-1, KEY-2' and the second part {{part2}} outputs 'KEY-3, KEY-4'?

The solution should be applicable regardless of how many keys {{example}} contains, whether it be any number between 1 and 100.

2 answers

1 accepted

0 votes
Answer accepted
Marc - Devoteam
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.
July 25, 2024

Hi @Ari Raatikainen 

As creating a variable puts out as a string, I think it should be possible to the use the variable with the split option.

{{example.split(",")}}

I currently have not time to test this myself, but I hope this might help you forward.

Ari Raatikainen
Contributor
July 25, 2024

Hi, see my reply to @Alex Koxaras _Relational_ - I am not looking for solution to split each value. Thanks. 

Marc - Devoteam
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.
July 26, 2024

Hi @Ari Raatikainen 

Then there is no solution ,as the comma is the only divider.

A Variable is a text string, so there is no option to determine the middle.

0 votes
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 25, 2024

Hi @Ari Raatikainen 

That smart function that @Marc - Devoteam provided should work in the case you want to split each value of that array. But you say you want to split it in the middle. And when you say middle, you mean the middle of the array size? What define "middle" for you?

Ari Raatikainen
Contributor
July 25, 2024

Hi @Alex Koxaras _Relational_ 

You are correct - I don't want split each value but split values in the middle of the array.

So if array values are: KEY-1, KEY-2, KEY-3, KEY-4 the middle is then comma after KEY-2

and if there is odd number of values e.g. KEY-1, KEY-2, KEY-3, KEY-4, KEY-5 the middle is comma after KEY-3. 

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events