So I'm trying to match all the instances of the word "test" exactly in a given text, and I'm using the following regex:
/(^|\s)test(\s|\.|$|,|!|\?|;|¿|¡)/gi
It works when the text is something like "this is a test. How is the test going? test." However, when you have two or more consecutive "test"'s it does not work.
ie:
var regex = /(^|\s)test(\s|\.|$|,|!|\?|;|¿|¡)/gi;
"test test test".match(regex);
//returns only ["test", "test"], should be ["test", "test", "test"]
What can I do to make the regex work with consecutive words?