[Edit]
+
0
-
0
js split string into array by comma and space
1 2 3 4 5 6 7 8 9 10const text1 = 'Split,this text'; const text2 = 'Another, , ,example,,,,text to , , , split'; // split strings const result1 = text1.split(/[ ,]+/); const result2 = text2.split(/[ ,]+/); // results: console.log(result1); // ['Split', 'this', 'text'] console.log(result2); // ['Another', 'example', 'text', 'to', 'split']