首页 > 代码库 > note

note

给字符串的字符和数字间加上空隔

var str = ‘a23dssf12ldf2lf4‘;function addSplit(str){    var reg = /(\D+)/g;    var str = str.replace(/(\d+)/g, ‘ $1 ‘);    return str.replace(/^\s+|\s+$/g,‘‘);}alert(addSplit(str));