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.
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.