How to split a string by space or comma in TypeScript

1 Answer

0 votes
const str = 'typescript, javascript node.js, c++ c';

const arr = str.split(/[ ,]+/);

console.log(arr); 


  
  
/*
run:

["typescript", "javascript", "node.js", "c++", "c"] 

*/

 



answered Apr 14, 2022 by avibootz

Related questions

...