aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/regexp/flags/index.md
blob: f03a085b928d99794c042fa139bceef232eac476 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
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
---
<div>{{JSRef}}</div>

<p>La propriété <strong><code>flags</code></strong> renvoie une chaîne de caractères contenant les <a href="/fr/docs/Web/JavaScript/Guide/Expressions_régulières#Effectuer_des_recherches_avanc.C3.A9es_en_utilisant_les_drapeaux_(flags)">drapeaux (<em>flags</em>)</a> de l'objet {{jsxref("RegExp")}} auquel elle appartient.</p>

<div>{{EmbedInteractiveExample("pages/js/regexp-prototype-flags.html")}}</div>



<div>{{js_property_attributes(0, 0, 1)}}</div>

<h2 id="Description">Description</h2>

<p>Les drapeaux de la propriété <code>flags</code> sont rangés par ordre alphabétique de gauche à droite.</p>

<h2 id="Exemples">Exemples</h2>

<h3 id="Utiliser_flags">Utiliser <code>flags</code></h3>

<pre class="brush: js">/toto/ig.flags;   // "gi"
/truc/myu.flags;  // "muy"
</pre>

<h2 id="Prothèse_d'émulation_(polyfill)">Prothèse d'émulation (<em>polyfill</em>)</h2>

<pre class="brush: js">if (RegExp.prototype.flags === undefined) {
  Object.defineProperty(RegExp.prototype, 'flags', {
    configurable: true,
    get: function() {
      return this.toString().match(/[gimuy]*$/)[0];
    }
  });
}
</pre>

<h2 id="Spécifications">Spécifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Spécification</th>
   <th scope="col">État</th>
   <th scope="col">Commentaires</th>
  </tr>
  <tr>
   <td>{{SpecName('ES2015', '#sec-get-regexp.prototype.flags', 'RegExp.prototype.flags')}}</td>
   <td>{{Spec2('ES2015')}}</td>
   <td>Définition initiale.</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-get-regexp.prototype.flags', 'RegExp.prototype.flags')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>

<p>{{Compat("javascript.builtins.RegExp.flags")}}</p>

<h2 id="Voir_aussi">Voir aussi</h2>

<ul>
 <li>{{jsxref("RegExp.prototype.source")}}</li>
</ul>