Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to remove the first occurrence of a character from a Smart Value string? Edited

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:

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?

1 answer

1 accepted

2 votes
Answer accepted

Hi @Doug Shapiro I think you can use replaceAll function (it works with regular expressions). It could be something like:

  • {{Score.replaceAll("(^1)","")}}

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!

Best regards,

@Doug Shapiro you're welcome, it is always pleasure to help someone who provide detailed information and asks understandable questions :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

⚡️NEW Group for Confluence Cloud Admins

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...

97 views 2 8
Read article

Community Events

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

Events near you