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

Glossary Term

RegExp.prototype[Symbol.match]()

2 tags 1 category

The Symbol.match method of RegExp instances specifies how String.prototype.match() should behave. In addition, its presence (or absence) can influence whether an object is regarded as a regular expression.

This method exists for customizing match behavior within RegExp subclasses. It is called internally in String.prototype.match(). For example, the following two examples return the same result.

If the regex is global (with the g flag), its lastIndex is first set to 0, so matching always starts from the beginning of the string, and the regex’s exec() method is repeatedly called until exec() returns null. If the current match is an empty string, the lastIndex would still be advanced — if the regex is Unicode-aware, it would advance by one Unicode code point; otherwise, it advances by one UTF-16 code unit.

Syntax example: regexp[Symbol.match](str)

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…