I'm trying to separate string by multiple delimiters and include them in the result. Considering all consecutive non-whitespace characters as individual words. Example: "I'm working on a new super-project wow. Yay!" becomes "!Yay .wow project-super new a on working I'm" My code sofar:
function test(string){
console.log(string.split(/([.'\!'+a-zA-Z]+)/g ).reverse().join(' ') );
}
var string ="I'm working on a new super-project wow. Yay!"
test(string)
the output so far is: Yay! wow. project - super new a on working I'm
I'm still getting the wrong result. Any help would be appreciated.