--- 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 ---
flags プロパティは、現在の正規表現オブジェクトのフラグから成る文字列を返します。
{{JS_Property_Attributes(0, 0, 1)}}
flags プロパティのフラグはアルファベット順にソートされます(左から右へ 例えば、"gimuy")。
/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")}}