<!--一个匹配字字符串是aabbcc或aaaabccc或者其他模式的运用-->
function isPattern(str, pattern) { let str_a = str.split(" "); let p_a = pattern.split(""); let noCpy = function (arr) { let temp = []; arr.forEach(element => { if (!temp.length || temp.indexOf(element) < 0) { temp.push(element) } }); return temp }; let str_a_noCpy = noCpy(str_a); let p_a_noCpy = noCpy(p_a); str_a_noCpy.forEach((e, index) => { str = str.replace(new RegExp(e, "gm"), p_a_noCpy[index]) }) str = str.replace(/s*/gm, "") return str == pattern }