split spring {office=Munich, department=880}

felix.weber August 13, 2021

hi there,

I am getting out of idea - even after reading tons of other amazing tricks read in the community


I have created a custom variable (reporterdetails) which contains below information - but both values will be variable - just example values

{office=Munich, department=880}


Using J4A I will need to split a string as I want to use these values in other jira fields

 I want to have the value for office and department 

ideally one result should be "Munich" (for the office") and the other one "880" (for the department)

I have managed to get the office value 

// returns "Munich"


however I don´t find a way yet just to get "880" 

// returns "department=880}"
// => however I then I would need remove "department=" & the ending "}"


Furthermore tried a lot using .match(<regex>) but this regex integration is just horrible in my mind - in short didn´t get it to work

Thought also to use .substring(X,Y)}} but I don´t know how to calculate it dynamically as the value (and length) will change.


3 answers

1 accepted

1 vote
Answer accepted
markwhaite August 13, 2021

Hi @felix.weber 

Would subStringAfter work? So something like this?


The remove would then lose the extra }

However, this does assume that the format of the variable will remain the same. So that department will always be last.

You could do the same for the first value with substringAfterFirst, but that will also get the second value.

I hope this helps in some way. And yes, regex's are evil. 

felix.weber August 16, 2021

hey @markwhaite it works - I thought I have tested this but obviously not in combination with .remove 

thx again

0 votes
felix.weber August 30, 2021

me again.. it is getting more complicate


the variable (JSON data) contains following informatoin:

{office=Munich, department=000 - Heros, managerID=123, managerEmail=test.user@domain.com, ID1=456, ID2=789}


can somebody help maybe with working regex / in J4A with .catch or similar ? I guess we are at the limits of the text manipulations ?!

felix.weber August 30, 2021

super strange this time it works like a charm

just changing .substring.after & .substring.before 

reporterdetails office = {{reporterdetails.substringBetween("{office=",",")}}
reporterdetails department = {{reporterdetails.substringAfter(", department=").substringBefore(", managerID")}}
reporterdetails managerID = {{reporterdetails.substringAfter(", managerID=").substringBefore(", managerEmail")}}

reporterdetails manager Email : {{reporterdetails.substringAfter(", managerEmail=").substringBefore(", ID1")}}
reporterdetails ID1 : {{reporterdetails.substringAfter(", ID1=").substringBefore(", ID2")}}
reporterdetails ID2" : {{reporterdetails.substringAfterLast("=").remove("}")}}

0 votes
felix.weber August 20, 2021

to make it bit more complicated:

{office=Munich, department=xxx, managerid=123456789}

I am able to get the value for office & manager ID

office = 

manager ID =


but I am struggeling to get the value for the department.

Tried e.g. to chain substringbetween, .substringafterlast etc like

only department: 
{{reporterdetails.substringBetween({{reporterdetails.substringAfter(", department=")}},{{reporterdetails.substringBeforeLast(",")}})}}

 however no result at all

felix.weber August 20, 2021

fixed it by myself:

{{reporterdetails.substringAfter(", department=").substringBeforeLast(",")}}

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events