Forums

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

Jira Automation String.Remove

Daniel Ballinger April 8, 2021

Hi all,

I am sure this is quite simple but not knowledge enough in smart rules to get this working. 

I am needed to remove numbers from a text string in which Jira Automation takes the custom field from a linked issue and inputs into the target issue. 

However I need to remove numeric values example 

Linked issue value:-Daniel11223344

 |Copied to Target issue value :- Daniel 

 

I have almost got it working with the following:-

{{issue.Unit/Site Name.remove("0")}}

This does remove the string "0" however cant figure out how to remove all other numbers i.e [0-9]

How do you include multiple values in .remove?

I have tried teh below with no luck

{{issue.Unit/Site Name.remove("[0-9]")}}

{{issue.Unit/Site Name.remove("0","1")}}

1 answer

1 accepted

2 votes
Answer accepted
Bill Sheboy
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.
April 8, 2021

Hi @Daniel Ballinger 

The function remove() gets rid of one character.  Maybe try replaceAll() instead using a regular expression:

{{issue.Unit/Site Name.replaceAll("([0-9])","")}}

Please look here for more information about that function, and the reference to regular expression syntax:

https://support.atlassian.com/jira-software-cloud/docs/smart-values-text-fields/

Best regards,

Bill

Daniel Ballinger April 8, 2021

Thanks Bill,

That did the trick. 

You could also use the remove function by doing the below but not very elegant

{{issue.Unit/Site Name.remove("0").remove("1").remove("2"}} etc etc

Like Bill Sheboy likes this
Bill Sheboy
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.
April 8, 2021

I am glad that helped.  And...I would expect that chained removal to be a bit slower, and "maintenance unfriendly".  ;^)

Daniel Ballinger April 8, 2021

Yeah its takes a second longer that way ...but every second counts right :-)

Suggest an answer

Log in or Sign up to answer