Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
global は RegExp インスタンスのプロパティで、g フラグが正規表現で使われているかどうかを返します。
RegExp.prototype.global は、g フラグが使用された場合は true、そうでない場合は false になります。g フラグは、正規表現が文字列内のすべての可能なマッチに対してテストされるべきであることを示します。 exec() を呼び出すたびに lastIndex プロパティが更新され、次の exec() の呼び出しが次の文字から始まるようになります。
String.prototype.matchAll() や String.prototype.replaceAll() のようないくつかのメソッドは、引数が正規表現である場合、それがグローバルであることを検証します。正規表現の [Symbol.match]() および [Symbol.replace]()(String.prototype.match() と String.prototype.replace() によって呼び出されます)も、正規表現がグローバルである場合に異なる動作をします。
global の設定アクセサーは undefined です。このプロパティを直接変更することはできません。
| ECMAScript® 2027 Language Specification # sec-get-regexp.prototype.global |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年11月10日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.