基本的に私は、正規表現を使用していmatchTestは、変数の言葉を一致させるために、正規表現を保持し、一致して、この配列を取り込むこと、およびには、この配列["{test1、test2}"、 "test3"、 "{test4、test5}"から単語を抽出し、それらを1つの配列の中にまとめるためのエレガントな方法がありますか?
["{ test1, test2 }", "test3", "{test4, test5}"]
から
["test1","test2","test3","test4","test5"]
に配列を入れたいです配列を同じループに固定します。
while (regexMatches = matchTest.exec(sourceCode)) {
testArray.push(regexMatches[1].replace(/\W/g, " ").split(" "));
testArray = [].concat(...testArray);
testArray = testArray.filter(testArray => testArray != '');
}
私のやり方はうまくいきますが、かなり面倒です。これを改善する方法についての助けをいただければ幸いです。
いい仕事です。私はそれを少し複雑に思っています.. – nnnnnn
実際にこの/ [^ \ w、]/gは、 – alejandro