search Method
Returns the position of the first substring match in a regular expression search.
function search(rgExp : RegExp) : Number
The following example illustrates the use of the search method.
function SearchDemo(){
var r, re; //Declare variables.
var s = "The rain in Spain falls mainly in the plain.";
re = /falls/i; //Create regular expression pattern.
r = s.search(re); //Search the string.
return(r); //Return the index to the first match
//or –1 if no match is found.
}
Show: