Somnath Muluk Somnath Muluk - 6 months ago 171
Javascript Question

Remove/ truncate leading zeros by javascript/jquery

Suggest solution for removing or truncating leading zeros from number(any string) by javascript,jquery.

Answer

You can use a regular expression that matches zeroes at the beginning of the string:

s = s.replace(/^0+/, '');
Comments