--- title: RegExp.prototype.flags slug: Web/JavaScript/Reference/Global_Objects/RegExp/flags tags: - ECMAScript 2015 - Eigenschaft - JavaScript - Prototyp - Referenz - RegExp - Regular Expressions - Reguläre Expressionen translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/flags ---
Die flags Eigenschaft gibt einen String mit den Flags des RegExp-Objektes zurück.
Der Code für dieses interaktive Beispiel ist in einem GitHub Repository gespeichert. Wenn du etwas zum Interaktiven-Beispiel-Project beitragen möchtest, klone bitte https://github.com/mdn/interactive-examples und sende uns Pull-Requests.
Flags in der flags Eigenschaft sind alphabetisch sortiert (von links nach rechts, z.B. "gimuy").
flags benutzen/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];
}
});
}
| Spezifikation | Status | Kommentar |
|---|---|---|
| {{SpecName('ES2015', '#sec-get-regexp.prototype.flags', 'RegExp.prototype.flags')}} | {{Spec2('ES2015')}} | Initielle Definition. |
| {{SpecName('ESDraft', '#sec-get-regexp.prototype.flags', 'RegExp.prototype.flags')}} | {{Spec2('ESDraft')}} |
{{Compat("javascript.builtins.RegExp.flags")}}