I am trying to look for a word in a String.
re = new RegExp("bob");
checkWord = re.test("This is bobby!");
if (checkWord) { break; }
I want checkWord = false as I am only looking for “bob”, but it checkWord = true as “bobby” contains the word “bob”. What can I do to solve this problem? Thanks.
You can achieve this with two different ways:
give boundries
or group them
Both will work.
This is the working example:
Example
And if you are working with array then loop through each and check individually.