diff --git a/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md b/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md index ebc12689d..fb0af09c8 100644 --- a/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md +++ b/9-regular-expressions/14-regexp-lookahead-lookbehind/1-find-non-negative-integers/solution.md @@ -1,9 +1,9 @@ -The regexp for an integer number is `pattern:\d+`. +L'expression régulière pour un nombre entier est `pattern:\d+`. -We can exclude negatives by prepending it with the negative lookbehind: `pattern:(?` tag, we must first find it. We can use the regular expression pattern `pattern:` for that. +Pour insérer après la balise ``, nous devons d'abord la trouver. Nous pouvons utiliser le modèle d'expression régulière `pattern:` pour cela. -In this task we don't need to modify the `` tag. We only need to add the text after it. +Dans cette tâche, nous n'avons pas besoin de modifier la balise ``. Nous n'avons qu'à ajouter le texte après. -Here's how we can do it: +Voici comment nous pouvons le faire : ```js run let str = '......'; @@ -11,9 +11,9 @@ str = str.replace(//, '$&

Hello

'); alert(str); // ...

Hello

... ``` -In the replacement string `$&` means the match itself, that is, the part of the source text that corresponds to `pattern:`. It gets replaced by itself plus `

Hello

`. +Dans la chaîne de remplacement, `$&` signifie la correspondance elle-même, c'est-à-dire la partie du texte source qui correspond à `pattern:`. Il est remplacé par lui-même suivi de `

Hello

`. -An alternative is to use lookbehind: +Une alternative consiste à utiliser lookbehind : ```js run let str = '......'; @@ -22,15 +22,15 @@ str = str.replace(/(?<=)/, `

Hello

`); alert(str); // ...

Hello

... ``` -As you can see, there's only lookbehind part in this regexp. +Comme vous pouvez le voir, il n'y a qu'une partie lookbehind dans cette expression régulière. -It works like this: -- At every position in the text. -- Check if it's preceeded by `pattern:`. -- If it's so then we have the match. +Cela fonctionne comme ceci : +- À chaque position dans le texte. +- Vérifiez s'il est précédé de `pattern:`. +- Si c'est le cas, nous avons le match. -The tag `pattern:` won't be returned. The result of this regexp is literally an empty string, but it matches only at positions preceeded by `pattern:`. +La balise `pattern:` ne sera pas renvoyée. Le résultat de cette expression régulière est littéralement une chaîne vide, mais elle ne correspond qu'aux positions précédées de `pattern:`. -So it replaces the "empty line", preceeded by `pattern:`, with `

Hello

`. That's the insertion after ``. +Il remplace donc la "ligne vide", précédée de `pattern:`, par `

Hello

`. C'est l'insertion après ``. -P.S. Regexp flags, such as `pattern:s` and `pattern:i` can also be useful: `pattern://si`. The `pattern:s` flag makes the dot `pattern:.` match a newline character, and `pattern:i` flag makes `pattern:` also match `match:` case-insensitively. +PS Les drapeaux d'expression régulière, tels que `pattern:s` et `pattern:i` peuvent également être utiles : `pattern://si`. Le drapeau `pattern:s` fait correspondre le point `pattern:.` à un caractère de retour à la ligne, et le drapeau `pattern:i` fait que `pattern:` correspond également à `match:` insensible à la casse. diff --git a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md index be1a259f6..c54624a04 100644 --- a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md +++ b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md @@ -1,10 +1,10 @@ -# Insert After Head +# Insérer après Body -We have a string with an HTML Document. +Nous avons une chaîne avec un document HTML. -Write a regular expression that inserts `

Hello

` immediately after `` tag. The tag may have attributes. +Écrivez une expression régulière qui insère `

Hello

` immédiatement après la balise ``. La balise peut avoir des attributs. -For instance: +Par exemple: ```js let regexp = /your regular expression/; @@ -20,7 +20,7 @@ let str = ` str = str.replace(regexp, `

Hello

`); ``` -After that the value of `str` should be: +Après cela, la valeur de `str` devrait être : ```html

Hello