GeezerVison is showing developer.mozilla.org — RegExp.prototype.global - JavaScript | MDN
RegExp.prototype.global
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The global accessor property of RegExp instances returns whether or not the g flag is used with this regular expression.
const regex1 = /foo/g;
console.log(regex1.global);
// Expected output: true
const regex2 = /bar/i;
console.log(regex2.global);
// Expected output: false
js
const globalRegex = /foo/g;
const str = "fooexamplefoo";
console.log(str.replace(globalRegex, "")); // example
const nonGlobalRegex = /foo/;
console.log(str.replace(nonGlobalRegex, "")); // examplefoo