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

Glossary Term

RegExp.prototype.global

2 tags 1 category

The global accessor property of RegExp instances returns whether or not the g flag is used with this regular expression.

RegExp.prototype.global has the value true if the g flag was used; otherwise, false. The g flag indicates that the regular expression should be tested against all possible matches in a string. Each call to exec() will update its lastIndex property, so that the next call to exec() will start at the next character.

Some methods, such as String.prototype.matchAll() and String.prototype.replaceAll(), will validate that, if the parameter is a regex, it is global. The regex’s [Symbol.match](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/Symbol.match) and [Symbol.replace](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/Symbol.replace) methods (called by String.prototype.match() and String.prototype.replace()) would also have different behaviors when the regex is global.

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…