How to extract all words from a string by multiple delimiters in JavaScript

1 Answer

0 votes
const s = "java,c++.c|python:c#?php=javascript";

const arr = s.split(/[\s.|:?,=]+/);
 
for (let i = 0; i < arr.length; i++) {
  	console.log(arr[i]);
}
 
 
 
 
/*
run:
 
"java"
"c++"
"c"
"python"
"c#"
"php"
"javascript"
 
*/

 



answered Apr 11, 2022 by avibootz
edited Apr 11, 2022 by avibootz

Related questions

...