A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags below:

RegExp.prototype.flags - JavaScript | MDN

RegExp.prototype.flags

Baseline Widely available

La propriété flags renvoie une chaîne de caractères contenant les drapeaux (flags) de l'objet RegExp auquel elle appartient.

Exemple interactif
// Outputs RegExp flags in alphabetical order

console.log(/foo/gi.flags);
// Expected output: "gi"

console.log(/bar/muy.flags);
// Expected output: "muy"
Écrivable Non Énumérable Non Configurable Oui Description

Les drapeaux de la propriété flags sont rangés par ordre alphabétique de gauche à droite.

Exemples Utiliser flags
/toto/gi.flags; // "gi"
/truc/muy.flags; // "muy"
Prothèse d'émulation (polyfill)
if (RegExp.prototype.flags === undefined) {
  Object.defineProperty(RegExp.prototype, "flags", {
    configurable: true,
    get: function () {
      return this.toString().match(/[gimuy]*$/)[0];
    },
  });
}
Spécifications Compatibilité des navigateurs Voir aussi

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4