Hi. I have a variable in a Jira Automation Rule that holds the contents of a calculation. I would like to remove the number 1 if it's the very first character in the string. Lets say my variable is "Score". I have been able to get this to work for me:
I found this example in: https://support.atlassian.com/jira-software-cloud/docs/smart-values-text-fields/
So, for example if "Score" = 108, after the above string removal, it becomes "08" The problem is, if Score=101, I will get a result of 0 since both occurrences of "1" are removed. I only want to remove the first one.
Looking at the String Utils mentioned in the above article, I tried to use this form:
but unfortunately it isn't working and the result is an empty string. I think I need to include another parameter to tell it to just return the source string if the first character is not "1" but I can't figure out how to format that.
Can anyone help?
Thank you very much @Martin Bayer _MoroSystems_ s_r_o__ - this seems to be working! I was concerned by the nomenclature "replaceAll" worried it would remove all occurrences of "1" and I would have the same problem I described but I tested the case of "101" and the result was "01" which is exactly what I wanted.
So, if you don't mind, I'm just trying to get better at this stuff and understand how this works - what keeps this string operation from removing all occurrences of the specified character? I thought it might have been the use of the caret but I tested without the caret and it still worked! So, what does that caret do?
Also, do you happen to know if .Startremove is supported and if so how I would have used it? That said, I'm delighted to use the .replaceAll and understand a bit more about how it works. Thanks again!!!
Hi @Doug Shapiro , sure, let's explain :)
@Martin Bayer _MoroSystems_ s_r_o__ Thanks for explaining all of this including confirming what the caret does. I clearly messed up my test without the caret. I just retested without the caret and as you say, without the caret, it did in fact replace all occurrences! So, "101" became "0". Thanks so much for helping me knock down this wall so I could get this string manipulation working the way I needed!
Calling all Confluence Cloud Admins! We created a new Community Group to support your unique needs as Confluence admins. This is a group where you can ask questions, access resou...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events