How to split a string with multiple delimiters in TypeScript

1 Answer

0 votes
const str = "TypeScript-is a-programming language:developed and:maintained*by Microsoft";
 
const arr = str.split(/[\s-:*]+/)
   
for (let i = 0; i < arr.length; i++) {
    console.log(arr[i]);
}
   
   
   
   
/*
run:
   
"TypeScript" 
"is" 
"a" 
"programming" 
"language" 
"developed" 
"and" 
"maintained" 
"by" 
"Microsoft" 
   
*/

 



answered Aug 6, 2022 by avibootz
...