var str = "01abc23中文4567中ad文89中文"; str=str.replace(/[^x00-xff]/g,"$&x01").replace(/.{10}x01?/g,"$& ").replace(/x01/g,""); alert(str);