Character classesClasses de caractères

A character class is how you say “I want ONE character out of these”:

  • /[aeiou]/ → one lowercase vowel;
  • /c[aou]t/ → “cat”, “cot”, “cut”, but not “cet”.

A class occupies the place of a single character, like the dot, but with an explicit list instead of “any one at all”. It is the first way of tightening a pattern that matches too much.

ExerciseExercice 4 · fixed or fixes, preciselypeux ou peut, version précise basicbasique not startedà faire solvedréussi keep tryingà retravailler
Find "fixed" and "fixes" with a character class. In this text the dot would no longer do: /fixe./ would also catch "fixer".
Trouvez « peux » et « peut » avec une classe de caractères. Dans ce texte, le point ne suffirait plus : /peu./ capturerait aussi « peur » et le début de « peuple ».
Test textTexte de test
The tool fixed the file and fixes the next. Do not fixate on it. A fixer is a person.
Je peux traduire, mais il ne peut pas. Peu importe, on n'a pas peur. Le peuple veut la paix.
Expected matches:Correspondances attendues : peux peut
Expected matches:Correspondances attendues : fixed fixes
//gmu

Our solution to exercise 1 "fixed or fixes"exercice 1 « peux ou peut », /fixe./, found “fixed” and “fixes” as well. The one here is better because it is more specific: /fixe[ds]/ will not hand you an unexpected match on “fixer”.

ExerciseExercice 5 · bat, but, bitbat, but, bit basicbasique not startedà faire solvedréussi keep tryingà retravailler
Find "bat", "but" and "bit", but not "bet" or "bot".
Trouvez « bat », « but » et « bit », mais pas « bet » ni « bot ».
Test textTexte de test
The bat hit the bit in the but. Better bet on the bot.
The bat hit the bit in the but. Better bet on the bot.
Expected matches:Correspondances attendues : bat bit but
Expected matches:Correspondances attendues : bat bit but
//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

Les classes de caractères permettent de dire « je veux UN caractère parmi ceux-ci » :

  • /[aeiou]/ → une voyelle minuscule ;
  • /ch[aiou]t/ → « chat », « chit », « chot », « chut », mais pas « chet ».

Une classe occupe donc la place d’un seul caractère, comme le point, mais avec une liste explicite au lieu de « n’importe lequel ». C’est le premier moyen de resserrer un motif trop large.

ExerciseExercice 4 · fixed or fixes, preciselypeux ou peut, version précise basicbasique not startedà faire solvedréussi keep tryingà retravailler
Find "fixed" and "fixes" with a character class. In this text the dot would no longer do: /fixe./ would also catch "fixer".
Trouvez « peux » et « peut » avec une classe de caractères. Dans ce texte, le point ne suffirait plus : /peu./ capturerait aussi « peur » et le début de « peuple ».
Test textTexte de test
The tool fixed the file and fixes the next. Do not fixate on it. A fixer is a person.
Je peux traduire, mais il ne peut pas. Peu importe, on n'a pas peur. Le peuple veut la paix.
Expected matches:Correspondances attendues : peux peut
Expected matches:Correspondances attendues : fixed fixes
//gmu

Notre solution pour l’exercise 1 "fixed or fixes"exercice 1 « peux ou peut », /peu./, trouvait elle aussi « peux » et « peut ». Celle-ci est meilleure parce qu’elle est plus précise : /peu[xt]/ ne vous donnera pas de correspondance inattendue sur « peur ».

ExerciseExercice 5 · bat, but, bitbat, but, bit basicbasique not startedà faire solvedréussi keep tryingà retravailler
Find "bat", "but" and "bit", but not "bet" or "bot".
Trouvez « bat », « but » et « bit », mais pas « bet » ni « bot ».
Test textTexte de test
The bat hit the bit in the but. Better bet on the bot.
The bat hit the bit in the but. Better bet on the bot.
Expected matches:Correspondances attendues : bat bit but
Expected matches:Correspondances attendues : bat bit but
//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.