if (test.indexOf("title") !=-1) { ... } // or... if (test.match("title")) { ... } // or... if("Watch out for the rock!".search(/for/) != -1) { ... }