Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我输入123A0001-123A0100后结果是100。或者如果123A0123-123A0200结果是78. 我该怎么做?请帮忙。
123A0001-123A0100
100
123A0123-123A0200
78
之前谢谢。
var str = 'A0001-A0100', match = str.match(/\d+/g); if (match) { alert(+match[1] - +match[0]); }
+(unary plus) 将字符串转换为数字(与 相同Number(...))。
+
Number(...)
jQuery有一个计算插件。
计算插件