--- title: RegExp.prototype.flags slug: Web/JavaScript/Reference/Global_Objects/RegExp/flags tags: - ECMAScript 2015 - JavaScript - Propriété - Prototype - Reference - RegExp - polyfill translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/flags original_slug: Web/JavaScript/Reference/Objets_globaux/RegExp/flags ---
La propriété flags
renvoie une chaîne de caractères contenant les drapeaux (flags) de l'objet {{jsxref("RegExp")}} auquel elle appartient.
Les drapeaux de la propriété flags
sont rangés par ordre alphabétique de gauche à droite.
flags
/toto/ig.flags; // "gi" /truc/myu.flags; // "muy"
if (RegExp.prototype.flags === undefined) { Object.defineProperty(RegExp.prototype, 'flags', { configurable: true, get: function() { return this.toString().match(/[gimuy]*$/)[0]; } }); }
Spécification | État | Commentaires |
---|---|---|
{{SpecName('ES2015', '#sec-get-regexp.prototype.flags', 'RegExp.prototype.flags')}} | {{Spec2('ES2015')}} | Définition initiale. |
{{SpecName('ESDraft', '#sec-get-regexp.prototype.flags', 'RegExp.prototype.flags')}} | {{Spec2('ESDraft')}} |
{{Compat("javascript.builtins.RegExp.flags")}}