Adaptavist Remove Text from strings

Created by Kristian Walker last modified
 * This script provides some example code that can be run on the console in Jira cloud and will get certain bits of text out fo a string'.
 * All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner 
 * license shall be granted a  non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed
 * or amended and must be included in any circumstances where the code snippet is shared by You or a third party." 

// --- Remove text in parentheses at the end of a string ---

def string = "demo (value in brackets)"
def parsedString = string.replaceAll(/\s?\(.*?\)/, "")

return parsedString

// --- Get just the issue key out of the url ---

def url = ""
def pattern = /[^\/]+$/
def matcher = (url =~ pattern)

if (matcher.find()) {
    def match =
    return match

Comments (0)


You can clone a snippet to your computer for local editing. Learn more.