Escaping special charactersÉchapper les caractères spéciaux

The dot stands in for any character. So how do you search for a real dot? By escaping it with a backslash (\):

  • /./ → any character;
  • /\./ → a literal dot.

The same goes for every metacharacter you will meet (*, +, ?, parentheses, square brackets…): with a \ in front, they go back to being ordinary characters.

ExerciseExercice 2 · a period followed by a spacepoint suivi d'une espace basicbasique not startedà faire solvedréussi keep tryingà retravailler
Find every period that is followed by a space.
Trouvez tous les points suivis d'une espace.
Test textTexte de test
End of sentence. New sentence. See e.g. Dr. Smith over there... No period here
Fin de phrase. Nouvelle phrase. Encore une s.v.p. M. Dupont est là... Pas de point ici
Expected matches:Correspondances attendues : . . . . . ␣ space · ⇥ tab · ⏎ line break · ◆ empty match␣ espace · ⇥ tabulation · ⏎ retour à la ligne · ◆ correspondance vide
Expected matches:Correspondances attendues : . . . . . ␣ space · ⇥ tab · ⏎ line break · ◆ empty match␣ espace · ⇥ tabulation · ⏎ retour à la ligne · ◆ correspondance vide
//gmu

The backslash is itself a special character, since it is the one that gives the escape signal. To search for it literally, you escape it with another backslash.

ExerciseExercice 3 · escaping the backslashéchapper la barre oblique inversée basicbasique not startedà faire solvedréussi keep tryingà retravailler
Find every backslash (\) in the text.
Trouvez toutes les barres obliques inversées (\) dans le texte.
Test textTexte de test
The path is C:\Users\Documents and not D:\Temp\ but http://example.com uses ordinary / slashes.
Le chemin est C:\Users\Documents et non D:\Temp\ mais http://example.com utilise des barres obliques / normales.
Expected matches:Correspondances attendues : \ \ \ \
Expected matches:Correspondances attendues : \ \ \ \
//gmu
Written alternately in EN and FR, translation partly generated in both directions. Rédigé en alternance en EN et en FR, traduction en partie générée dans les deux sens. Updated 2026-08-27

Le point remplace n’importe quel caractère. Comment chercher un vrai point, alors ? En l’échappant avec une barre oblique inversée (\) :

  • /./ → n’importe quel caractère ;
  • /\./ → un point littéral.

Le même principe vaut pour tous les métacaractères que vous rencontrerez (*, +, ?, les parenthèses, les crochets…) : précédés de \, ils redeviennent des caractères ordinaires.

ExerciseExercice 2 · a period followed by a spacepoint suivi d'une espace basicbasique not startedà faire solvedréussi keep tryingà retravailler
Find every period that is followed by a space.
Trouvez tous les points suivis d'une espace.
Test textTexte de test
End of sentence. New sentence. See e.g. Dr. Smith over there... No period here
Fin de phrase. Nouvelle phrase. Encore une s.v.p. M. Dupont est là... Pas de point ici
Expected matches:Correspondances attendues : . . . . . ␣ space · ⇥ tab · ⏎ line break · ◆ empty match␣ espace · ⇥ tabulation · ⏎ retour à la ligne · ◆ correspondance vide
Expected matches:Correspondances attendues : . . . . . ␣ space · ⇥ tab · ⏎ line break · ◆ empty match␣ espace · ⇥ tabulation · ⏎ retour à la ligne · ◆ correspondance vide
//gmu

La barre oblique inversée est elle-même un caractère spécial, puisque c’est elle qui donne le signal d’échappement. Pour la chercher littéralement, on l’échappe donc avec une autre barre oblique inversée.

ExerciseExercice 3 · escaping the backslashéchapper la barre oblique inversée basicbasique not startedà faire solvedréussi keep tryingà retravailler
Find every backslash (\) in the text.
Trouvez toutes les barres obliques inversées (\) dans le texte.
Test textTexte de test
The path is C:\Users\Documents and not D:\Temp\ but http://example.com uses ordinary / slashes.
Le chemin est C:\Users\Documents et non D:\Temp\ mais http://example.com utilise des barres obliques / normales.
Expected matches:Correspondances attendues : \ \ \ \
Expected matches:Correspondances attendues : \ \ \ \
//gmu
Written alternately in EN and FR, translation partly generated in both directions. Rédigé en alternance en EN et en FR, traduction en partie générée dans les deux sens. Mise à jour 2026-08-30

Sources

Sources

Spotted an error? Une erreur ?

Language, content, a broken link: tell me what you saw and I will fix it. Langue, contenu, lien brisé : dites-moi ce que vous avez vu et je corrige.

Sending opens your mail app with the report addressed to me. L'envoi ouvre votre application de courriel avec le signalement déjà adressé à moi.