Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

String.prototype.search()

2 tags 1 category

The search() method of String values executes a search for a match between a regular expression and this string, returning the index of the first match in the string.

The implementation of String.prototype.search() doesn’t do much other than calling the Symbol.search method of the argument with the string as the first parameter. The actual implementation comes from RegExp.prototype[Symbol.search](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/Symbol.search).

The g flag of regexp has no effect on the search() result, and the search always happens as if the regex’s lastIndex is 0. For more information on the behavior of search(), see RegExp.prototype[Symbol.search](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/Symbol.search).

Syntax example: search(regexp)

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…