Skip to content

Commit f04235c

Browse files
committed
first pass on first paragraphe
1 parent 7cea7f6 commit f04235c

File tree

1 file changed

+11
-11
lines changed
  • 9-regular-expressions/10-regexp-greedy-and-lazy

1 file changed

+11
-11
lines changed

9-regular-expressions/10-regexp-greedy-and-lazy/article.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Greedy and lazy quantifiers
22

3-
Quantifiers are very simple from the first sight, but in fact they can be tricky.
3+
Les quantificateurs sont, à première vue, très simples, mais peuvent parfois être retors.
44

5-
We should understand how the search works very well if we plan to look for something more complex than `pattern:/\d+/`.
5+
Nous devons mieux comprendre comment marche une recherche pour arriver à trouver des modèles plus complexes que `pattern:/\d+/`.
66

7-
Let's take the following task as an example.
7+
Prenons comme exemple la tâche suivante.
88

9-
We have a text and need to replace all quotes `"..."` with guillemet marks: `«...»`. They are preferred for typography in many countries.
9+
Nous avons un texte dans lequel nous devons remplacer tous les guillemets droits (doubles) `"..."` par des guillemets français : `«...»`, qui sont préférés en typographie dans de nombreux pays.
1010

11-
For instance: `"Hello, world"` should become `«Hello, world»`. There exist other quotes, such as `„Witam, świat!”` (Polish) or `「你好,世界」` (Chinese), but for our task let's choose `«...»`.
11+
Par exemple : `"Hello, world"` devrait se transformer en `«Hello, world»`. Il existe d'autre guillemets, comme `„Witam, świat!”` (polonais) ou `「你好,世界」` (chinois), mais pour notre exemple choisissons `«...»`.
1212

13-
The first thing to do is to locate quoted strings, and then we can replace them.
13+
La première chose à faire est de trouver ces guillemets droits, et nous pourrons alors les remplacer.
1414

15-
A regular expression like `pattern:/".+"/g` (a quote, then something, then the other quote) may seem like a good fit, but it isn't!
15+
Une expression régulière comme `pattern:/".+"/g` (des guillemets, puis quelque chose, puis d'autres guillemets) semble être une bonne approche, mais pas exactement !
1616

17-
Let's try it:
17+
Essayons ça:
1818

1919
```js run
2020
let regexp = /".+"/g;
@@ -24,11 +24,11 @@ let str = 'a "witch" and her "broom" is one';
2424
alert( str.match(regexp) ); // "witch" and her "broom"
2525
```
2626

27-
...We can see that it works not as intended!
27+
... Nous pouvons voir que ça ne marche exactement comme prévu !
2828

29-
Instead of finding two matches `match:"witch"` and `match:"broom"`, it finds one: `match:"witch" and her "broom"`.
29+
Au lieu de trouver deux correspondances `match:"witch"` et `match:"broom"`, il n'en trouve qu'une : `match:"witch" and her "broom"`.
3030

31-
That can be described as "greediness is the cause of all evil".
31+
Qui peut être vu comme "l'avidité est la cause de tout mal".
3232

3333
## Greedy search
3434

0 commit comments

Comments
 (0)