标签:字符串 join regexp return 字符 turn str cti nbsp
function Xreplace(str,length,reversed)
{
var re = new RegExp("\\d{1,"+length+"}","g");
ma = str.match(re);
if(reversed)ma.reverse();
return ma.join("a") + "a";//最后面不要"a" 就去掉( + "a")
}
alert(Xreplace("000100020003",4));
alert(Xreplace("000100020003",4,true));
alert(Xreplace("000100020003",4,false));
标签:字符串 join regexp return 字符 turn str cti nbsp
原文地址:http://www.cnblogs.com/Jonecmnn/p/7810694.html