I'm trying to perform a whole word search in javascript using the following regex.
str = Test String C.S (example);
var regex_search = new RegExp(\b+search_string+\b,g);
if(str.match(regex_search)) != null)
match = true;
else
match = false;
The above works well if I search for a normal string like 'String'. But if I search for just 'S', it returns C.S as a match. Also, searching for example returns a match but in this case I do not want a match because it has parenthesis. I just want to match the whole word only. Any suggestions would be greatly appreciated.
--Edit--
Thanks to @plalx Clarified the example.