String.prototype.search() Method in String Class of Javascript Syntax with Examples
2313 Views
Usage
search() function is used to find the position of string in the main string or sentence.
Note:
This function is case sensitive.To omit case sensitive can follow some syntax.
Syntax
string.search("searchString")
Example
var userName = "cristiano ronaldo";
//if string present
var char1 = userName.search("ronaldo");
document.write("string position is "+char1+" .");
//if string not present
var char2 = userName.search("Ronaldo");
document.write("string position is "+char2+".");