var res = "a-b-c-d";var index = find(res,'-',1); //字符串res中第二个‘-’的下标 var ress = res.substring(index); //ress的值为 "-c-d" function find(str,cha,num){ var x=str.indexOf(cha); for(var i=0;i<num;i++){ x=str.indexOf(cha,x+1); } return x;}
var re1 = /(\d{1,3})+(?:\.\d+)?/g var re2 = /[\u4e00-\u9fa5]{2,}/g var str="11我22们33两个"; var arr1 = str.match(re1); var arr2 = str.match(re2); arr1=11,22,33 arr2=我,们,两个