How to remove prefix zeros for string

1
Dear all, How can I remove all prefix zeros from String value without using ParseInteger caused the string could have alphabet letters 00012Abc → 12Abc
asked
3 answers
6

You can do this with

replaceFirst($YourString, '0*' ,'')

Tested this with this result:

So this does not touch any other ‘0’s appearing later in the string.

answered
0

Hi Emad,

 

You can create a MF to remove the prefix zero’s. (example below)

Create a boolean variable (e.g PrefixZero), set a while loop with the condition PrefixZero is true.

In the while loop you add a decision that checks if the string starts with a ‘0’ (startsWith($origString,’0’).

If this is true you can change the origstring by removing the first zero (replaceFirst($origString,’0’) 

If the outcome of the decision is false you set the boolean PrefixZero on false and break the loop event.

SO in you example you will have following string values

00012Abc → true → 0012Abc → true → 012Abc → true → 12Abc → false → break loop

answered
0

example:
replaceFirst('000ABC00D','^0*','')

answered