Basically, I need to split a string to remove any exact matches.
Here’s what I tried.
let str = 'a abc a a bac';
let m = 'a';
str.split(m);
the result will remove all occurrences of the variable in the str. I need a way to put a variable inside a /^$/ regex to get only the exact matches. Any suggestions ?
2
Answers
It sounds like you want to split your input into "words", then filter out some of the words. This can be achieved by using
split
followed byfilter
: