javascriptjquerynumberszero

Remove/ truncate leading zeros by javascript/jquery


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


Solution

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

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