function getstr(str){
var s = new Array();
s =str.split(',');
var string = new Array();
var temp="";
var j=0;
for(var i = 0; i < s.length; i++){
var isStartSingleQuotes = s[i].indexOf("《");
var isEndSingleQuotes = s[i].indexOf("》");
if (temp.length>0) {
if (isEndSingleQuotes>0) {
temp += "," + s[i];
string[j]=temp;j++;
temp = "";
} else {
temp += "," + s[i];
}
continue;
}
if (isStartSingleQuotes>0) {
if (isEndSingleQuotes>0) {
string[j]=s[i];j++;
} else {
temp += s[i];
}
} else {
string[j]=s[i];j++;
}
}
return string;
}
js 以逗号分隔将字符串转化为数组,但字符串中包含逗号 例如:QB/T 1361-2014《红烧猪肉类罐头》,GB 1886.71-2015《食品安全国家标准 食品添加剂 1,2-二氯乙烷》
最新推荐文章于 2022-09-12 14:07:54 发布