复制代码代码如下所示:

功能的子串(STR,Len,hasdot)
{
无功newlength = 0;
VaR纽世达= ;
无功chineseregex = / { ^ 设备- xff } /克;
无功singlechar = ;
无功strlength = str.replace(chineseregex,**的长度);
对于(var i = 0;i < strlength;i++){
singlechar = str.charat(我)ToString();
如果(singlechar.match(chineseregex)!= NULL){
newlength = 2;
其他{ }
newlength + +;
}
如果(newlength > Len){
打破;
}
纽世达= singlechar;
}

如果(hasdot strlength > Len){
=纽世达…;
}
返回纽世达;
}
警报(字符串(js截取没有随机码中英文串