This is the regular expression that i have:
new RegExp("\\b" + synonym.toLowerCase() + "\\b", "g").test(modSearchString.toLowerCase())
So the scenario is that modSearchString contains a string of characters/words. It is checking if the modSearchString contains the synonym and if it does to do something. Now, it has been working really well. However, it doesn't seem to work if the synonym contains a plus sign. Most of these synonyms don't have a plus sign, but there will be a possibility that some will. How can I also account for the plus sign?
EDIT
I want it so that the phrase in modSearchString, matches exactly, with the synonym passed. So, if the synonym is "ThisPass+", and modSearchstring = 'Test for ThisPass++"
, it should fail. However, it should pass if modSearchstring = 'Test for ThisPass+"
.
The same should go with if the synonym was "ThisPass". It should pass if modSearchstring = 'Test for ThisPass"
and fail if modSearchstring = 'Test for ThisPass+"
.
The first regex i have works well in finding an the search string contains that synonym. However, that would only work if it's word characters. Since, the synonym may contain a + sign it'll probably not work well.