How to split a string by multiple spaces in TypeScript

1 Answer

0 votes
const str = 'typescript javascript node.js php';

const arr = str.trim().split(/\s+/);

console.log(arr); 


    
  
  
/*
run:
  
["typescript", "javascript", "node.js", "php"] 
  
*/

 



answered Apr 29, 2022 by avibootz
...