Microsoft® JScript® search Method |
Language Reference Version 3 |
Description
Returns the position of the first substring match in a regular expression search.
Syntax
stringObj.search(rgexp)The search method syntax has these parts:
Part Description stringObj Required. The String object or literal to search. rgexp Required. A Regular Expression object containing the pattern to search for.
Remarks
The search method indicates if a match is present or not. If a match is found, the search method returns an integer value that indicates the offset from the beginning of the string where the match occurred. If no match is found, it returns -1. To get further information, use the match method.The following example illustrates the use of the search method:
function SearchDemo() { var r, re; var s = "The quick brown fox jumped over the lazy yellow dog."; re = /fox/i; r = s.search(re); return(r); }