ParseInteger function is removing leading zeroes in string value

0
Hi All, Am converting a string to integer using parseInteger function. Issue is, this string has a value like “008976”, after parseInteger ouput is “8976”. Leading zeroes are getting lost. Could anyone please tell me how to convert string to integer without losing leading zeroes?
asked
3 answers
2

You can't have leading zeroes when parsing to an Integer, because leading zeroes have no mathematical value.

Your best bet would be to keep it as a String if you need the zeroes

answered
1

An integer doesn’t contain leading zeros, as leading zeros imply a string. You can replace all non-numeric characters instead if you’re just trying to ‘get all numbers contained in a string’.

replaceAll($String, ‘([^0-9])’, ‘’) should do what you’re trying to accomplish.

answered
0

This is a very tricky one because integers/  numbers just don't start with a 0 otherwise what number will it actually be?

You will have to keep it as a string in order to keep the zeros in the beginning. 

answered