var str = "01abc23中文4567中ad文89中文";
str=str.replace(/[^\x00-\xff]/g,"$&\x01").replace(/.{10}\x01?/g,"$&\n").replace(/\x01/g,"");
alert(str);
文字按固定个数换行
最新推荐文章于 2022-10-25 11:36:36 发布
var str = "01abc23中文4567中ad文89中文";
str=str.replace(/[^\x00-\xff]/g,"$&\x01").replace(/.{10}\x01?/g,"$&\n").replace(/\x01/g,"");
alert(str);