From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/regexp/flags/index.html | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/regexp/flags/index.html (limited to 'files/ja/web/javascript/reference/global_objects/regexp/flags/index.html') diff --git a/files/ja/web/javascript/reference/global_objects/regexp/flags/index.html b/files/ja/web/javascript/reference/global_objects/regexp/flags/index.html new file mode 100644 index 0000000000..22ce044b2d --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/regexp/flags/index.html @@ -0,0 +1,73 @@ +--- +title: RegExp.prototype.flags +slug: Web/JavaScript/Reference/Global_Objects/RegExp/flags +tags: + - ECMAScript 2015 + - JavaScript + - Property + - Prototype + - Reference + - RegExp + - Regular Expressions +translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/flags +--- +
{{JSRef}}
+ +

flags プロパティは、現在の正規表現オブジェクトのフラグから成る文字列を返します。

+ +
{{EmbedInteractiveExample("pages/js/regexp-prototype-flags.html")}}
+ + + +

{{JS_Property_Attributes(0, 0, 1)}}

+ +

解説

+ +

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(/[gimsuy]*$/)[0];
+    }
+  });
+}
+
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName("ESDraft", "#sec-get-regexp.prototype.flags", "RegExp.prototype.flags")}}
+ +

ブラウザーの互換性

+ + + +

{{Compat("javascript.builtins.RegExp.flags")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf