Somnath Muluk Somnath Muluk - 7 months ago 216
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+/, '');