window.ENTITIES={'/api/snippets/javascript/js%20split%20string%20into%20array%20by%20comma%20and%20space':[{"result":true,"message":null,"batch":{"type":"javascript","name":"js split string into array by comma and space","items":[{"id":"pry25D","type":"javascript","name":"js split string into array by comma and space","content":"myString.split(/[ ,]+/);","source":"","author":{"id":"EagrqD","name":"Frida-Timms","avatar":"1629030403109__EagrqD__w40px_h40px.png","points":667,"role":"BASIC"},"creationTime":1636489875000,"updateTime":null,"removalTime":null},{"id":"1w599p","type":"javascript","name":"js split string into array by comma and space","content":"const text1 = 'Split,this text';\nconst text2 = 'Another, , ,example,,,,text to , , , split';\n\n// split strings\nconst result1 = text1.split(/[ ,]+/);\nconst result2 = text2.split(/[ ,]+/);\n\n// results:\nconsole.log(result1); // ['Split', 'this', 'text']\nconsole.log(result2); // ['Another', 'example', 'text', 'to', 'split']","source":"","author":{"id":"dDYEkD","name":"Kenya-Spears","avatar":"1629030411873__dDYEkD__w40px_h40px.png","points":860,"role":"BASIC"},"creationTime":1636489876000,"updateTime":null,"removalTime":null},{"id":"Dk7LgD","type":"javascript","name":"js split string into array by comma and space","content":"function splitString(string) {\n return string.split(/[ ,]+/);\n}\n\n\n\n// Usage example:\n\nconst text1 = 'Split,this text';\nconst text2 = 'Another, , ,example,,,,text to , , , split';\n\nconsole.log( splitString(text1) ); // ['Split', 'this', 'text']\nconsole.log( splitString(text2) ); // ['Another', 'example', 'text', 'to', 'split']","source":"","author":{"id":"1DqRAa","name":"Aston-Freeman","avatar":"1629030392665__1DqRAa__w40px_h40px.png","points":787,"role":"BASIC"},"creationTime":1636489878000,"updateTime":null,"removalTime":null}]}}]};