You could use regular expressions:
how
Example:
/how/i.test(searchOnstring);
If you want to have a variable word (e.g. from a user input), you have to pay attention to not include special RegExp characters.
You have to escape them, for example with the function provided in the MDN (scroll down a bit):
function escapeRegExp(string){
return string.replace(/([.*+?^=!:${}()|[]/\])/g, "\$1");
}
var regex = '\b';
regex += escapeRegExp(yourDynamicString);
regex += '\b';
new RegExp(regex, "i").test(searchOnstring);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…