且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Javascript通过数字或alpha字符将字符串拆分为块

更新时间:2022-11-14 16:08:13

匹配角色然后加入它们可能更明智:

It may be more sensible to match the characters and then join them:

str = str.match(/(\d+|[^\d]+)/g).join(',');

但是在定义字符串时不要省略引号:

But don't omit the quotes when you define the string:

var str = 'A123B234C456';