Hi everyone!
I'm looking for an expression that has the ability to look at a string and eliminate leading zeros. 0000017856 to become 17856. Can anyone assist?
I greatly appreciate it!
Solved! Go to Solution.
Much more effective approach you'll find here.
@BenderMatt please find my flow, which replaces 0 with blank values.
--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
@BenderMatt There is one issue with my solution is that if the string has 0 anywhere it will removed, so assuming that you will have first 5 characters as 0 and you only need characters after that, we can use substring which will give us correct results even if the later part of the string has 0.
This does not remove 0 from the latter part of the string.
Expression to truncate first 5 characters :
substring(variables('varZero'),5)
--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Much more effective approach you'll find here.
Thank you all, for the help! That got it!
Glad to help.
using float() was the simplest solution that worked for me
does not work, for values that have zero in the value and bring characters:
- '0000023034'
- '0ABC0D'
in this case how would you apply
Hi @RamiroMatos,
did you test this?
Based on this original question/answer I used a Do Until with a check using string function StartsWith: startsWith(variables('TEST'),'0') is not equal to 'true'.
Instead of the check on: first(variables('TEST')) is not equal to 0, which only worked for removing a zero once.
This change resulted in the desired output.
Also, if an empty string can occur put the do until loop in a Condition checking for the string equal to '', otherwise it will fail.