Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

split/parse a value return with Regex

wajih zouaoui
Contributor
July 16, 2020

Hello,

 

i need to split a return value string and then create a list with it.

Like i have a returned value with ABCD-12345ABCD-67891 and i need to split this result and have a list with [ABCD-12345,ABCD-67891] using regex 

 

def sampleText = "ABCD-12345ABCD-67891"
return sampleText.split("regex TBD")

[ABCD-12345,ABCD-67891]

 I need the Regex to be used in order to have the result  similar to the format shown as a list.

 

Thanks in advance.

1 answer

1 accepted

0 votes
Answer accepted
brbojorque
Community Champion
July 16, 2020

Hi @wajih zouaoui ,

You can refer to the sample script below.

def matcher = sampleText =~ /TBD-[0-9]/
matcher.find()
if(matcher.size()){
matcher.each{
log.debug(it)
}
}

You can find how it works in real script here.

https://community.atlassian.com/t5/Jira-Software-questions/How-to-automatically-link-the-Jira-ticket-if-we-paste-Jira-link/qaq-p/1252935

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events