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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ?!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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("}")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
fixed it by myself:
{{reporterdetails.substringAfter(", department=").substringBeforeLast(",")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.