const str111 = `“asdd”eeeeeeeeeeeeeee`;
const filterStr = (str, ipt) => {
if (!str.length || str === ipt || !ipt || !str.includes(ipt)) return str;
let str1 = "",
str2 = "";
for (let i = 0; i < str.length; i++) {
if (ipt.includes(str[i]) && !str1.includes(str[i])) {
console.log("str[i] :>> ", str[i]);
str1 += str[i];
} else {
str2 += str[i];
}
}
return [str1, str2];
};
console.log(" filterStr() :>> ", filterStr(str111, `“asdd”`));
标签:ipt,函数,str2,str1,filterStr,includes,偶尔,str,工具
From: https://www.cnblogs.com/hjk1124/p/17616556.html