Say your line is:
let str = 'word1 word2;word3,word4,word5;word7 word8,word9;word10';
You want to split the string into the following delimiters:
You can split the string as follows:
let rawElements = str.split(new RegExp('[,;\n]', 'g'));
Finally, you may need to trim the elements in the array:
let elements = rawElements.map(element => element.trim());
Bobzius Jan 21 '19 at 17:33 2019-01-21 17:33
source share