一、常用字符串处理:
var str="ab,cd,e,2016-08-11";
var newStr="1234";
//1.截取:b,
document.write(str.substring(1,3)+ '</br>');
//2.拼接:1234ab,cd,e,2016-08-11
newStr+=str;
document.write(newStr+ '</br>');
//3.根据关键字转数组:ab,cd,e,2016-08-11
newStr=str.split(",");
document.write(newStr+ '</br>');
document.write(newStr[1]+ '</br>');//cd
//4.全部替换:ab,cd,e,2016/08/11
newStr=str.replace(new RegExp("-","gm"),"/");
document.write(newStr+ '</br>');
//5.只替换第一个: ab,cd,e,2016/08-11
newStr=str.replace("-","/");
document.write(newStr+ '</br>');