I want to match whole words using the JS function “index()”
I want to return -1 on this:
var str="hello I am a string";
alert(str.index("str")); //it matches because of STRing, but don't want
Edit: But I strictly want to match “str” only when it appears sorounded by two spaces (but also matching when it is at the beginning/end of a sentence). So \b don’t work for me because I do NOT want to allow "hello I am str. how are you?"to match
Maybe this will work: