var s = \'ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890\';
function f(s, width){
return s.replace(
new RegExp(\'[\\\\s\\\\S]{1,\'+(width || 4)+\'}\', \'g\'),
function(m){
return \'^\' + new Array(m.length).join(\' \');
});
}
console.log(s);
console.log(f(s, 4));
console.log(f(s, 8));
本文地址:https://www.stayed.cn/item/4639
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我