This article is in need of an editorial review.
This translation is in progress.
これは Harmony(ECMAScript 6) 提案の一部であり、実験段階の技術です。
この技術の仕様は安定していません。ブラウザ互換性の一覧表を確認してください。またこれらの構文や動作は、仕様変更などにより、新しいバージョンのブラウザでは変更される可能性があるという点に注意してください。
概要
現在の正規表現オブジェクトのフラグから成る文字列を返します。
Property attributes of RegExp.prototype.flags |
|
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | yes |
説明
flagsプロパティのフラグはアルファベット順にソートされます(左から右へ 例えば、 "gimuy")。
例
例: flagsを使う
/foo/ig.flags; // "gi" /bar/myu.flags; // "muy"
互換性
if (RegExp.prototype.flags === undefined) {
Object.defineProperty(RegExp.prototype, 'flags', {
configurable: true,
get: function() {
return this.toString().match(/[gimuy]*$/)[0];
}
});
}
仕様
| 仕様 | ステータス | コメント |
|---|---|---|
| ECMAScript 6 (ECMA-262) The definition of 'RegExp.prototype.flags' in that specification. |
勧告候補 | Initial definition. |
ブラウザ実装状況
| 機能 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| 基本サポート | 未サポート | 37 (37) | 未サポート | 未サポート | 未サポート |
| 機能 | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| 基本サポート | 未サポート | 未サポート | 37.0 (37) | 未サポート | 未サポート | 未サポート |