I am trying to get special symbols like !@# etc but whenever i use string.split(/\W+/g) it return special symbols but along with whitespaces, which i dont want, from string apple is fruit! i want to get ! only, how do i do it?
function test(string) {
let res = '';
let splittedStr = string.split(/\W+/);
let symbols = [];
let test = string.matchAll(/\W+/g)
for (elem of test) console.log(elem)
return [splittedStr, res];
}
console.log(test("apple is fruit!"));