Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,461,945
Community Members
 
Community Events
176
Community Groups

split spring {office=Munich, department=880}

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 

{{reporterdetails.substringBetween("{office=",",")}}
// returns "Munich"

 

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

{{reporterdetails.split(",").last}}
// 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

Hi @felix.weber 

Would subStringAfter work? So something like this?

{{data.substringAfterLast("=").remove("}")}}

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. 

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

thx again

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 ?!

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("}")}}

to make it bit more complicated:

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

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

office = 
{{reporterdetails.substringBetween("{office=",",")}}


manager ID =
{{reporterdetails.substringAfterLast("=").remove("}")}} 

 

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

fixed it by myself:

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

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events