Finds the first substring match in a regular expression search.
SyntaxstringObj.search( rgExp )
If a match is found, the search method returns an integer value that indicates the offset from the beginning of the string where the first match occurred. If no match is found, it returns -1.
ExamplesThe following example illustrates the use of the search method.
var src = "is but a Dream within a dream";
var re = /dream/;
var pos = src.search(re);
document.write(pos);
document.write("<br/>");
re = /dream/i;
pos = src.search(re);
document.write(pos);
Remarks
You can also set the i flag that causes the search to be case-insensitive.
See also Other articlesMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4