find value from string in javascript code example
Example 1: find in string javascript
stringToBeSearched.search(stringToBeFound);
Example 2: find from string in javascript
var str = "Please locate where 'locate' occurs!";
var ind1 = str.indexOf("locate");
var ind2 = str.lastIndexOf("locate");
var ind3 = str.indexOf("locate", 15);
var ind4 = str.search("locate");
document.write("<br>" + "Length of string:", len);
document.write("<br>" + "indexOf:", ind1);
document.write("<br>" + "index of last:", ind2);
document.write("<br>" + "indexOf with start point:", ind3);
document.write("<br>" + "search:", ind4);