Practice: predict the matchesExercices : prédire les correspondances
/\d{3}-\d{4}/Which matches will be found?
/\d{3}-\d{4}/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
/\b[A-Z]\w+/Test text (French): Prénoms: Marie, Pierre et Montréal.
Which matches will be found?
/\b[A-Z]\w+/Texte de test : Prénoms : Marie, Pierre et Montréal.
Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
\w covers [A-Za-z0-9_] only: the accents stop it. "Prénoms" becomes "Pr" and "Montréal" becomes "Montr".\w ne couvre que [A-Za-z0-9_] : les accents l'arrêtent. « Prénoms » devient « Pr » et « Montréal » devient « Montr »./colou?r/Which matches will be found?
/colou?r/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
? makes the "u" optional: zero or one occurrence, never more.? rend le « u » optionnel : zéro ou une occurrence, jamais plus./[aeiou]{3}/Which matches will be found?
/[aeiou]{3}/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
/\d+\.\d+/Which matches will be found?
/\d+\.\d+/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
\. is a literal dot: decimal numbers in the English format, not commas and not hyphens.\. est un point littéral : des nombres décimaux au format anglo-saxon, pas des virgules ni des tirets./\s+/What will be found?
/\s+/Qu'est-ce qui sera trouvé ?
Show the solutionVoir la solution
\s covers every whitespace character, and + groups them into blocks.\s couvre tous les caractères d'espacement, et + les regroupe en blocs./[^0-9]+/What will be found?
/[^0-9]+/Qu'est-ce qui sera trouvé ?
Show the solutionVoir la solution
^ at the head of the class inverts the selection: any character that is not a digit, punctuation and spaces included.^ en tête de classe inverse la sélection : tout caractère qui n'est pas un chiffre, ponctuation et espaces compris./\b\w{5}\b/Test text: hello world and 12345 hi bye bonjour salut
Which matches will be found?
/\b\w{5}\b/Texte de test : hello world and 12345 hi bye bonjour salut
Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
\w, so "12345" qualifies too.\w, donc « 12345 » aussi./ca+t/Which matches will be found?
/ca+t/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
+ demands at least one "a" and accepts several. "ct" fails (zero "a"), and a+ has nothing to do with a wildcard.+ exige au moins un « a » et en accepte plusieurs. « ct » échoue (zéro « a »), et a+ n'a rien à voir avec un joker./\p{L}{3}/Which matches will be found?
/\p{L}{3}/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
\p{L} covers every Unicode letter, accents included; three in a row.\p{L} couvre toutes les lettres Unicode, accents compris ; trois d'affilée./^\d{3}$/Which matches will be found?
/^\d{3}$/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
^ and $ frame the whole line: exactly 3 digits and nothing else on it.^ et $ encadrent la ligne entière : exactement 3 chiffres, rien d'autre sur la ligne./[A-Z]{2,4}/Which matches will be found?
/[A-Z]{2,4}/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
To close
You have been through the whole module: literal characters and the wildcard, escaping, classes, ranges and negation, whitespace, the shorthand classes, Unicode properties, anchors, word boundaries, repetition, groups and greedy behaviour. Even once the details of the syntax fade, the essentials stay: knowing that this system exists, recognising the problems it solves (patterns to find, formats to validate, text to clean up), and being able to read an expression back to judge what it really matches.
/\d{3}-\d{4}/Which matches will be found?
/\d{3}-\d{4}/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
/\b[A-Z]\w+/Test text (French): Prénoms: Marie, Pierre et Montréal.
Which matches will be found?
/\b[A-Z]\w+/Texte de test : Prénoms : Marie, Pierre et Montréal.
Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
\w covers [A-Za-z0-9_] only: the accents stop it. "Prénoms" becomes "Pr" and "Montréal" becomes "Montr".\w ne couvre que [A-Za-z0-9_] : les accents l'arrêtent. « Prénoms » devient « Pr » et « Montréal » devient « Montr »./colou?r/Which matches will be found?
/colou?r/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
? makes the "u" optional: zero or one occurrence, never more.? rend le « u » optionnel : zéro ou une occurrence, jamais plus./[aeiou]{3}/Which matches will be found?
/[aeiou]{3}/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
/\d+\.\d+/Which matches will be found?
/\d+\.\d+/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
\. is a literal dot: decimal numbers in the English format, not commas and not hyphens.\. est un point littéral : des nombres décimaux au format anglo-saxon, pas des virgules ni des tirets./\s+/What will be found?
/\s+/Qu'est-ce qui sera trouvé ?
Show the solutionVoir la solution
\s covers every whitespace character, and + groups them into blocks.\s couvre tous les caractères d'espacement, et + les regroupe en blocs./[^0-9]+/What will be found?
/[^0-9]+/Qu'est-ce qui sera trouvé ?
Show the solutionVoir la solution
^ at the head of the class inverts the selection: any character that is not a digit, punctuation and spaces included.^ en tête de classe inverse la sélection : tout caractère qui n'est pas un chiffre, ponctuation et espaces compris./\b\w{5}\b/Test text: hello world and 12345 hi bye bonjour salut
Which matches will be found?
/\b\w{5}\b/Texte de test : hello world and 12345 hi bye bonjour salut
Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
\w, so "12345" qualifies too.\w, donc « 12345 » aussi./ca+t/Which matches will be found?
/ca+t/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
+ demands at least one "a" and accepts several. "ct" fails (zero "a"), and a+ has nothing to do with a wildcard.+ exige au moins un « a » et en accepte plusieurs. « ct » échoue (zéro « a »), et a+ n'a rien à voir avec un joker./\p{L}{3}/Which matches will be found?
/\p{L}{3}/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
\p{L} covers every Unicode letter, accents included; three in a row.\p{L} couvre toutes les lettres Unicode, accents compris ; trois d'affilée./^\d{3}$/Which matches will be found?
/^\d{3}$/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
^ and $ frame the whole line: exactly 3 digits and nothing else on it.^ et $ encadrent la ligne entière : exactement 3 chiffres, rien d'autre sur la ligne./[A-Z]{2,4}/Which matches will be found?
/[A-Z]{2,4}/Quelles correspondances seront trouvées ?
Show the solutionVoir la solution
Pour conclure
Vous avez traversé tout le module : les caractères littéraux et le joker, l’échappement, les classes, les plages et la négation, les blancs, les classes abrégées, les propriétés Unicode, les ancres, les limites de mot, les répétitions, les groupes et le comportement gourmand. Même si les détails de la syntaxe s’estompent avec le temps, l’essentiel restera : savoir que ce système existe, reconnaître les problèmes qu’il résout (des motifs à chercher, des formats à valider, du texte à nettoyer), et pouvoir relire une expression pour juger ce qu’elle capture vraiment.