From 844f5103992238c0c23203286dad16a466e89c97 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:09 +0200 Subject: move *.html to *.md --- .../global_objects/regexp/@@matchall/index.html | 106 --------------------- .../global_objects/regexp/@@matchall/index.md | 106 +++++++++++++++++++++ 2 files changed, 106 insertions(+), 106 deletions(-) delete mode 100644 files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.html create mode 100644 files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.md (limited to 'files/fr/web/javascript/reference/global_objects/regexp/@@matchall') diff --git a/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.html b/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.html deleted file mode 100644 index 303390a68c..0000000000 --- a/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.html +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: RegExp.prototype[@@matchAll]() -slug: Web/JavaScript/Reference/Global_Objects/RegExp/@@matchAll -tags: - - JavaScript - - Méthode - - Prototype - - Reference - - RegExp -translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/@@matchAll -original_slug: Web/JavaScript/Reference/Objets_globaux/RegExp/@@matchAll ---- -

{{JSRef}}

- -

La méthode [@@matchAll] renvoie l'ensemble des correspondances d'une expression rationnelle sur une chaîne de caractères.

- -
{{EmbedInteractiveExample("pages/js/regexp-prototype-@@matchall.html")}}
- -

Syntaxe

- -
regexp[Symbol.matchAll](str)
- -

Paramètres

- -
-
str
-
Une chaîne de caractères ({{jsxref("String")}}) dont on souhaite trouver les correspondances.
-
- -

Valeur de retour

- -

Un itérateur.

- -

Description

- -

Cette méthode est appelée, en interne, par le moteur JavaScript, pendant l'exécution {{jsxref("String.prototype.matchAll()")}}. Les deux lignes qui suivent renverront donc le même résultat.

- -
'abc'.matchAll(/a/);
-
-/a/[Symbol.matchAll]('abc');
- -

Cette méthode existe afin de personnaliser le comportement des correspondances pour les sous-classes de RegExp.

- -

Exemples

- -

Appel direct

- -

Cette méthode peut être utilisée de façon semblable à {{jsxref("String.prototype.matchAll()")}} mais l'objet this et l'ordre des arguments seront différents.

- -
var re = /[0-9]+/g;
-var str = '2016-01-02';
-var resultat = re[Symbol.matchAll](str);
-
-console.log(Array.from(resultat, x => x[0]));
-// ["2016", "01", "02"]
-
- -

Utiliser @@matchAll dans une sous-classe

- -

Les sous-classes de {{jsxref("RegExp")}} peuvent surcharger la méthode [@@matchAll]() afin de modifier le comportement par défaut (par exemple pour renvoyer un tableau ({{jsxref("Array")}}) plutôt qu'un itérateur).

- -
class MaRegExp extends RegExp {
-  [Symbol.matchAll](str) {
-    var resultat = RegExp.prototype[Symbol.matchAll].call(this, str);
-    if (!resultat) {
-      return null;
-    } else {
-      return Array.from(resultat);
-    }
-  }
-}
-
-var re = new MaRegExp('([0-9]+)-([0-9]+)-([0-9]+)', 'g');
-var str = '2016-01-02|2019-03-07';
-var resultat = str.matchAll(re);
-console.log(resultat[0]); // [ "2016-01-02", "2016", "01", "02" ]
-console.log(resultat[1]); // [ "2019-03-07", "2019", "03", "07" ]
-
- -

Spécifications

- - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ESDraft', '#sec-regexp-prototype-matchall', 'RegExp.prototype[@@matchAll]')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

{{Compat("javascript.builtins.RegExp.@@matchAll")}}

- -

Voir aussi

- - diff --git a/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.md b/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.md new file mode 100644 index 0000000000..303390a68c --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/regexp/@@matchall/index.md @@ -0,0 +1,106 @@ +--- +title: RegExp.prototype[@@matchAll]() +slug: Web/JavaScript/Reference/Global_Objects/RegExp/@@matchAll +tags: + - JavaScript + - Méthode + - Prototype + - Reference + - RegExp +translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/@@matchAll +original_slug: Web/JavaScript/Reference/Objets_globaux/RegExp/@@matchAll +--- +

{{JSRef}}

+ +

La méthode [@@matchAll] renvoie l'ensemble des correspondances d'une expression rationnelle sur une chaîne de caractères.

+ +
{{EmbedInteractiveExample("pages/js/regexp-prototype-@@matchall.html")}}
+ +

Syntaxe

+ +
regexp[Symbol.matchAll](str)
+ +

Paramètres

+ +
+
str
+
Une chaîne de caractères ({{jsxref("String")}}) dont on souhaite trouver les correspondances.
+
+ +

Valeur de retour

+ +

Un itérateur.

+ +

Description

+ +

Cette méthode est appelée, en interne, par le moteur JavaScript, pendant l'exécution {{jsxref("String.prototype.matchAll()")}}. Les deux lignes qui suivent renverront donc le même résultat.

+ +
'abc'.matchAll(/a/);
+
+/a/[Symbol.matchAll]('abc');
+ +

Cette méthode existe afin de personnaliser le comportement des correspondances pour les sous-classes de RegExp.

+ +

Exemples

+ +

Appel direct

+ +

Cette méthode peut être utilisée de façon semblable à {{jsxref("String.prototype.matchAll()")}} mais l'objet this et l'ordre des arguments seront différents.

+ +
var re = /[0-9]+/g;
+var str = '2016-01-02';
+var resultat = re[Symbol.matchAll](str);
+
+console.log(Array.from(resultat, x => x[0]));
+// ["2016", "01", "02"]
+
+ +

Utiliser @@matchAll dans une sous-classe

+ +

Les sous-classes de {{jsxref("RegExp")}} peuvent surcharger la méthode [@@matchAll]() afin de modifier le comportement par défaut (par exemple pour renvoyer un tableau ({{jsxref("Array")}}) plutôt qu'un itérateur).

+ +
class MaRegExp extends RegExp {
+  [Symbol.matchAll](str) {
+    var resultat = RegExp.prototype[Symbol.matchAll].call(this, str);
+    if (!resultat) {
+      return null;
+    } else {
+      return Array.from(resultat);
+    }
+  }
+}
+
+var re = new MaRegExp('([0-9]+)-([0-9]+)-([0-9]+)', 'g');
+var str = '2016-01-02|2019-03-07';
+var resultat = str.matchAll(re);
+console.log(resultat[0]); // [ "2016-01-02", "2016", "01", "02" ]
+console.log(resultat[1]); // [ "2019-03-07", "2019", "03", "07" ]
+
+ +

Spécifications

+ + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ESDraft', '#sec-regexp-prototype-matchall', 'RegExp.prototype[@@matchAll]')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ +

{{Compat("javascript.builtins.RegExp.@@matchAll")}}

+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf