How to extract all words from a string by multiple delimiters in Node.js

1 Answer

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

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

 



answered Apr 11, 2022 by avibootz

Related questions

...