You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi,
I am currently trying to remove a part of a string in ScriptRunner.
The string looks like this:
foobar (DASD)
Everything between and including the brackets should be removed. I have already tried various methods, but so far without success.
Can someone provide me with a suitable method?
Thank you very much!
Hi Benjamin,
As ScriptRunner for Jira Cloud runs Groovy, you should use the replaceAll method as documented here.
Using this, you would assign your string to a variable, and then you could call replace all on it using a regular expression to remove everything inside and including the brackets, as shown in the example here.
ScriptRunner is using the Groovy language, therefore your question translates to: how can I remove the suffix including the space charater?
Here is the answer, although it removes the suffix including a dot character: https://stackoverflow.com/questions/34321526/groovy-way-to-remove-file-extension
You can easily change the '.' to ' ' and bingo!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thx
def customFieldValueCleaned = customFieldValue.take(customFieldValue.lastIndexOf('('))
does exactly what I want!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.