通过 javascript/jquery 删除/截断前导零

2022-01-17 00:00:00 numbers jquery zero javascript

建议通过 javascript、jquery 从数字(任何字符串)中删除或截断前导零的解决方案.

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

推荐答案

您可以使用匹配字符串开头的零的正则表达式:

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

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

相关文章