You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The multiline mode is enabled by the flag`pattern:m`.
3
+
Le mode multiligne est activé avec le marqueur`pattern:m`.
4
4
5
-
It only affects the behavior of `pattern:^`and`pattern:$`.
5
+
Il affecte seulement le fonctionnement des ancres `pattern:^`et`pattern:$`.
6
6
7
-
In the multiline mode they match not only at the beginning and the end of the string, but also at start/end of line.
7
+
Dans le mode multiligne, elles ne vérifient pas seulement le début et la fin d'une chaîne de caractères, mais également le début et la fin d'une ligne.
8
8
9
-
## Searching at line start ^
9
+
## Recherche au début de ligne ^
10
10
11
-
In the example below the text has multiple lines. The pattern`pattern:/^\d/gm`takes a digit from the beginning of each line:
11
+
Dans l'exemple ci-dessous, le texte comporte plusieurs lignes. Le paterne`pattern:/^\d/gm`prend un chiffre au début de chaque ligne:
That's because by default a caret `pattern:^`only matches at the beginning of the text, and in the multiline mode -- at the start of any line.
35
+
Cela est dû au fait que, par défaut, l'accent circonflexe `pattern:^`ne vérifie que le début d'un texte, et dans le mode multiligne -- le début de n'importe quelle ligne.
36
36
37
37
```smart
38
-
"Start of a line" formally means "immediately after a line break": the test `pattern:^` in multiline mode matches at all positions preceeded by a newline character `\n`.
39
-
40
-
And at the text start.
38
+
"Début de ligne" désigne formellement "immédiatement après un saut à la ligne" : le test `pattern:^` en mode multiligne vérifie à toutes les positions suivant un caractère de retour à la ligne `\n`, en plus du début du texte.
41
39
```
42
40
43
-
## Searching at line end $
41
+
## Recherche en fin de ligne $
44
42
45
-
The dollar sign `pattern:$`behaves similarly.
43
+
Le signe dollar `pattern:$`se comporte similairement.
46
44
47
-
The regular expression `pattern:\d$`finds the last digit in every line
45
+
L'expression régulière `pattern:\d$`prend le premier chiffre à la fin de chaque ligne.
48
46
49
47
```js run
50
48
let str =`Winnie: 1
@@ -54,21 +52,19 @@ Eeyore: 3`;
54
52
alert( str.match(/\d$/gm) ); // 1,2,3
55
53
```
56
54
57
-
Without the flag `m`, the dollar `pattern:$`would only match the end of the whole text, so only the very last digit would be found.
55
+
Sans le marqueur `pattern:m`, le signe dollar `pattern:$`vérifierait uniquement la fin de tout le texte, donc uniquement le tout dernier chiffre serait trouvé.
58
56
59
57
```smart
60
-
"End of a line" formally means "immediately before a line break": the test `pattern:$` in multiline mode matches at all positions succeeded by a newline character `\n`.
61
-
62
-
And at the text end.
58
+
"Fin de ligne" désigne formellement "immédiatement avant un saut à la ligne" : le test `pattern:$` en mode multiligne vérifie à toutes les positions précédant un caractère de retour à la ligne `\n`, en plus de la fin du texte.
63
59
```
64
60
65
-
## Searching for \n instead of ^ $
61
+
## Recherche de \n au lieu de ^ $
66
62
67
-
To find a newline, we can use not only anchors `pattern:^`and`pattern:$`, but also the newline character`\n`.
63
+
Pour chercher un retour à la ligne, nous pouvons non seulement utiliser les ancres `pattern:^`et`pattern:$`, mais également le caractère de retour à la ligne`\n`.
68
64
69
-
What's the difference? Let's see an example.
65
+
Quelle est la différence ? Regardons un exemple.
70
66
71
-
Here we search for `pattern:\d\n`instead of`pattern:\d$`:
67
+
Ici, nous cherchons `pattern:\d\n`au lieu de`pattern:\d$`:
72
68
73
69
```js run
74
70
let str =`Winnie: 1
@@ -78,10 +74,10 @@ Eeyore: 3`;
78
74
alert( str.match(/\d\n/gm) ); // 1\n,2\n
79
75
```
80
76
81
-
As we can see, there are 2 matches instead of 3.
77
+
Comme nous pouvons le voir, il y a 2 correspondances au lieu de 3.
82
78
83
-
That's because there's no newline after `subject:3` (there's text end though, so it matches`pattern:$`).
79
+
C'est parce qu'il n'y a pas de retour à la ligne après `subject:3` (il y a la fin du texte cependant, donc ça correspond avec`pattern:$`).
84
80
85
-
Another difference: now every match includes a newline character `match:\n`. Unlike the anchors`pattern:^``pattern:$`, that only test the condition (start/end of a line), `\n`is a character, so it becomes a part of the result.
81
+
Une autre différence : maintenant, chaque correspondance inclue un caractère de retour à la ligne `match:\n`. Contrairement aux ancres`pattern:^``pattern:$`, qui ne testent qu'une condition (début/fin d'une ligne), `\n`est un caractère, donc il devient une partie du résultat.
86
82
87
-
So, a`\n`in the pattern is used when we need newline characters in the result, while anchors are used to find something at the beginning/end of a line.
83
+
Ainsi, un`\n`dans le paterne est utilisé quand nous avons besoin dudit caractère dans le résultat, tandis que les ancres sont utilisées pour chercher quelque chose au début/à la fin d'une ligne.
0 commit comments