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
Copy file name to clipboardExpand all lines: 9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md
-15Lines changed: 0 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,6 @@
1
1
Pour insérer après la balise `<body>`, nous devons d'abord la trouver. Nous pouvons utiliser le modèle d'expression régulière `pattern:<body.*?>` pour cela.
2
2
3
-
<<<<<<< HEAD
4
3
Dans cette tâche, nous n'avons pas besoin de modifier la balise `<body>`. Nous n'avons qu'à ajouter le texte après.
5
-
=======
6
-
In this task, we don't need to modify the `<body>` tag. We only need to add the text after it.
Comme vous pouvez le voir, il n'y a qu'une partie lookbehind dans cette expression régulière.
30
26
31
-
<<<<<<< HEAD
32
27
Cela fonctionne comme ceci :
33
28
- À chaque position dans le texte.
34
29
- Vérifiez s'il est précédé de `pattern:<body.*?>`.
@@ -37,15 +32,5 @@ Cela fonctionne comme ceci :
37
32
La balise `pattern:<body.*?>` 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:<body.*?>`.
38
33
39
34
Il remplace donc la "ligne vide", précédée de `pattern:<body.*?>`, par `<h1>Hello</h1>`. C'est l'insertion après `<body>`.
40
-
=======
41
-
It works like this:
42
-
- At every position in the text.
43
-
- Check if it's preceded by `pattern:<body.*?>`.
44
-
- If it's so, then we have the match.
45
-
46
-
The tag `pattern:<body.*?>` won't be returned. The result of this regexp is literally an empty string, but it matches only at positions preceded by `pattern:<body.*?>`.
47
-
48
-
So it replaces the "empty line", preceded by `pattern:<body.*?>`, with `<h1>Hello</h1>`. That's the insertion after `<body>`.
49
-
>>>>>>> bf7d8bb1af3b416d393af1c15b03cb1352da1f9c
50
35
51
36
PS Les drapeaux d'expression régulière, tels que `pattern:s` et `pattern:i` peuvent également être utiles : `pattern:/<body.*?>/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:<body>` correspond également à `match:<BODY>` insensible à la casse.
0 commit comments