This article is in need of an editorial review.
This translation is incomplete. Please help translate this article from English.
非標準
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
概要
非標準の leftContext プロパティは、最新の一致の左側の部分文字列を含む正規表現の静的で読み取り専用のプロパティです。RegExp.$`はこのプロパティに対するエイリアスです。
構文
RegExp.leftContext
RegExp['$`']
説明
leftContext プロパティは静的プロパティです。個々の正規表現オブジェクトのプロパティではありません。そのかわりに、常に、RegExp.leftContext または RegExp['$`'].として使用してください。
leftContext プロパティの値は、読み取り専用で、一致が成功したときはいつでも変更されます。
ドットプロパティアクセス(RegExp.$`)の速記のエイリアスを使用しないでください。というのも、パーサはその場合に開始テンプレート文字列を期待し、SyntaxErrorがスローされるからです。プロパティへのアクセスにブラケット表記法を使用してください。
例
例: leftContext と $`を使う
var re = /world/g;
re.test("hello world!");
RegExp.leftContext; // "hello "
RegExp['$`']; // "hello "
仕様
非標準。すべての現在の仕様でサポートされておりません。
ブラウザ実装状況
| 機能 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| 基本サポート | (有) | (有) | (有) | (有) | (有) |
| 機能 | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| 基本サポート | (有) | (有) | (有) | (有) | (有) | (有) |