Jira automation string manipulation with regex

Rees_ Ian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2024

Hi, in my automation I have a string that ends with the string ": CHGnnnnnn" where n is any digit.

I want to remove the " : CHGnnnnnn" part from the string so I am left with the root e.g. "iantest99 : CHG000123" becomes "iantest99".

I have tried 

{{varSource.remove(" : CHG[0-9][0-9][0-9][0-9][0-9][0-9]")}} and other variations on the regex, but I can't get it to work. Any ideas ?

 

3 answers

1 accepted

1 vote
Answer accepted
Rees_ Ian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2024

I've achieved what I want using replaceall and replacing with an empty string

Rees_ Ian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2024

{{varSource.replaceAll("CHG[0-9]*$","")}} did the trick

0 votes
tena lena
Banned
June 7, 2024

Jira's automation capabilities are significantly enhanced by incorporating string manipulation using regular expressions (regex). Regex allows users to define patterns for identifying and extracting specific data from text fields within Jira issues. This can be particularly useful for tasks such as formatting text, extracting key information, or validating input. For example, you can automate the extraction of ticket numbers from comments, format issue summaries to meet naming conventions, or ensure that custom field inputs match a specified pattern. By leveraging regex in Jira automation, users can streamline workflows, reduce manual data entry errors, and ensure consistency across projects, ultimately boosting productivity and efficiency within the platform.

0 votes
Duc Thang TRAN
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2024

Hello @Rees_ Ian 

If i want understand correctly , you want to remove : ": CHGnnnnnn" from your field "iantest99 : CHG000123" to get "iantest99"

Can you try with this smart value 

{{issue.customfield.substringBefore(" : CHGnnnnnn")}}

 

Hope this can help :)

Duc Thang TRAN
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2024

replace customefield by the name of your field

Duc Thang TRAN
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2024

Correction 

{{issue.customfield.substringBefore(" : CHG")}}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events