Practice: find the expressionExercices : trouver l'expression

ExerciseExercice 13 not startedà faire solvedréussi keep tryingà retravailler
Test text: The chair, the cheese and the child are here.
Which expression finds exactly these highlighted words?
Texte de test : Le chat noir, le chien blanc et le cheval brun courent.
Quelle regex trouve exactement ces mots surlignés ?
Show the solutionVoir la solution
Answer: b) and d). ch\w+ and ch[aie]\w* both work. ch[aie] captures three letters only ("cha", "che", "chi"), and ch.+, being greedy, swallows everything to the end of the line.
Réponse : b) et d). ch\w+ et ch[aie]\w* fonctionnent tous les deux. ch[aie] ne capture que trois lettres (« cha », « chi », « che »), et ch.+, gourmand, avale tout jusqu'à la fin de la ligne.
ExerciseExercice 14 not startedà faire solvedréussi keep tryingà retravailler
Test text: There are 5 apples, 42 oranges, 123 bananas and 4567 seeds.
Which expression finds exactly these highlighted numbers?
Texte de test : Il y a 5 pommes, 42 oranges, 123 bananes et 4567 graines.
Quelle regex trouve exactement ces nombres surlignés ?
Show the solutionVoir la solution
Answer: b) and d). \d+ and [0-9]+ are equivalent. \d finds one digit at a time, and \d{1,3} would cut "4567" into "456" and "7".
Réponse : b) et d). \d+ et [0-9]+ sont équivalents. \d ne trouve qu'un chiffre à la fois, et \d{1,3} découperait « 4567 » en « 456 » et « 7 ».
ExerciseExercice 15 not startedà faire solvedréussi keep tryingà retravailler
Test text: Follow @mary and @john123 as well as @_test on social media.
Which expression finds exactly these highlighted mentions?
Texte de test : Suivez @marie et @jean123 ainsi que @_test sur les réseaux.
Quelle regex trouve exactement ces mentions surlignées ?
Show the solutionVoir la solution
Answer: a) and d). @\w+ and @[a-zA-Z0-9_]+ are equivalent: \w is exactly [a-zA-Z0-9_]. @[a-z]+ would miss the digits and the underscore; @.+ is far too greedy.
Réponse : a) et d). @\w+ et @[a-zA-Z0-9_]+ sont équivalents : \w est exactement [a-zA-Z0-9_]. @[a-z]+ manquerait les chiffres et le trait de soulignement ; @.+ est trop gourmand.
ExerciseExercice 16 not startedà faire solvedréussi keep tryingà retravailler
Test text: Postal codes: H3C 2K4 and V6B 1A1 are valid, but h3c 2k4 and 123 456 are not.
Which expression finds exactly these highlighted codes?
Texte de test : Codes postaux : H3C 2K4 et V6B 1A1 valides, mais h3c 2k4 et 123 456 sont invalides.
Quelle regex trouve exactement ces codes surlignés ?
Show the solutionVoir la solution
Answer: a). Only [A-Z]\d[A-Z] \d[A-Z]\d imposes the exact letter-digit sequence in capitals. b) and d) would accept the lowercase version ("h3c 2k4"), and c) would accept "123 456".
Réponse : a). Seule [A-Z]\d[A-Z] \d[A-Z]\d impose l'alternance exacte en majuscules. b) et d) accepteraient les minuscules (« h3c 2k4 »), et c) accepterait « 123 456 ».
ExerciseExercice 17 not startedà faire solvedréussi keep tryingà retravailler
Test text: Important dates: 01/12/2023 and 25/08/2024, but not 5/3/2025.
Which expression finds exactly these highlighted dates?
Texte de test : Dates importantes : 01/12/2023 et 25/08/2024, mais pas 5/3/2025.
Quelle regex trouve exactement ces dates surlignées ?
Show the solutionVoir la solution
Answer: a) and b). \d{2}/\d{2}/\d{4} is the idiomatic form; the long version gives the same matches. c) and d) would accept "5/3/2025" as well.
Réponse : a) et b). \d{2}/\d{2}/\d{4} est la forme idiomatique ; la version longue donne les mêmes correspondances. c) et d) accepteraient aussi « 5/3/2025 ».
ExerciseExercice 18 not startedà faire solvedréussi keep tryingà retravailler
Test text: URGENT: ABcd and WARNING are important.
Which expression finds exactly these highlighted words in capitals?
Texte de test : URGENT : ABcd et ATTENTION sont importants.
Quelle regex trouve exactement ces mots en majuscules surlignés ?
Show the solutionVoir la solution
Answer: c). \b[A-Z]+\b demands whole words in capitals. b) and d) would also capture "AB" inside "ABcd", with no word boundary to stop them.
Réponse : c). \b[A-Z]+\b exige des mots entiers en majuscules. b) et d) captureraient aussi « AB » dans « ABcd », sans limite de mot.
ExerciseExercice 19 not startedà faire solvedréussi keep tryingà retravailler
Test text: Prices: 15,99 €, 100,00 € and 2000,50 € (not 5,999 € or 50X99 €).
Which expression finds exactly these highlighted prices?
Texte de test : Prix : 15,99 €, 100,00 € et 2000,50 € (pas 5,999 € ni 50X99 €).
Quelle regex trouve exactement ces prix surlignés ?
Show the solutionVoir la solution
Answer: b). \d+,\d{2} € demands exactly two decimals. a) would accept "5,999 €"; c) would capture only "000,50 €" inside "2000,50 €"; d), with its unescaped dot, would also capture "50X99 €".
Réponse : b). \d+,\d{2} € exige exactement 2 décimales. a) accepterait « 5,999 € » ; c) ne capturerait que « 000,50 € » dans « 2000,50 € » ; d), avec son point non échappé, capturerait aussi « 50X99 € ».
ExerciseExercice 20 not startedà faire solvedréussi keep tryingà retravailler
Test text (French): Expressions: peut-être and week-end are common.
Which expression finds exactly these highlighted compounds?
Texte de test : Expressions : peut-être et week-end sont courantes.
Quelle regex trouve exactement ces mots composés surlignés ?
Show the solutionVoir la solution
Answer: b). \p{L} handles the "ê" of "peut-être". \w and [a-z] both fail on accents, and .+-.+ is far too permissive.
Réponse : b). \p{L} gère le « ê » de « peut-être ». \w et [a-z] échouent sur les accents, et .+-.+ est beaucoup trop permissif.
ExerciseExercice 21 not startedà faire solvedréussi keep tryingà retravailler
Test text: Abbreviations: Mr. Dupont and Dr. Martin in the text.
Which expression finds exactly these highlighted abbreviations?
Texte de test : Abréviations : M. Dupont et Dr. Martin dans le texte.
Quelle regex trouve exactement ces abréviations surlignées ?
Show the solutionVoir la solution
Answer: c). [A-Z][a-z]*\. accepts "Mr." and "Dr.". a) has an unescaped dot (a wildcard); b) fails on "Dr." (the r is lowercase); d) would also capture "text." at the end of the sentence.
Réponse : c). [A-Z][a-z]*\. accepte « M. » et « Dr. ». a) a un point non échappé (joker) ; b) échoue sur « Dr. » (le r est minuscule) ; d) capturerait aussi « texte. » en fin de phrase.
ExerciseExercice 22 not startedà faire solvedréussi keep tryingà retravailler
Test text: Percentages: 15%, 99.5% and 100% (not the incomplete 15.%).
Which expression finds exactly these highlighted percentages?
Texte de test : Pourcentages : 15%, 99,5% et 100% (pas 15.% incomplet).
Quelle regex trouve exactement ces pourcentages surlignés ?
Show the solutionVoir la solution
Answer: c). The optional group (\.\d+)? covers both cases. a) misses "99.5%"; b) demands a decimal part and misses "15%"; d) would also accept "15.%".
Réponse : c). Le groupe optionnel (,\d+)? couvre les deux cas. a) manque « 99,5% » ; b) exige une décimale et manque « 15% » ; d) accepterait aussi « 15.% ».
ExerciseExercice 23 not startedà faire solvedréussi keep tryingà retravailler
Test text: Websites: http://example.com and https://google.com are reachable.
Which expression finds exactly these highlighted URLs?
Texte de test : Sites web : http://example.com et https://google.com sont accessibles.
Quelle regex trouve exactement ces URL surlignées ?
Show the solutionVoir la solution
Answer: a) and d). https? and http[s]? both make the "s" optional, one with ? on a character, the other with an optional class.
Réponse : a) et d). https? et http[s]? rendent tous deux le « s » optionnel, l'un avec ? sur un caractère, l'autre avec une classe optionnelle.
ExerciseExercice 24 not startedà faire solvedréussi keep tryingà retravailler
Test text: HTML: <P>text</P> and <div>content</div> with <SPAN>element</SPAN>.
Which expression finds exactly these highlighted opening tags?
Texte de test : HTML : <P>texte</P> et <div>contenu</div> avec <SPAN>élément</SPAN>.
Quelle regex trouve exactement ces balises ouvrantes surlignées ?
Show the solutionVoir la solution
Answer: c). <\w+> captures the opening tags, capitals included. a) is greedy (one giant match), b) would capture the closing tags too, d) would miss <P> and <SPAN>.
Réponse : c). <\w+> capture les balises ouvrantes, majuscules comprises. a) est gourmande (une seule correspondance géante), b) capturerait aussi les balises fermantes, d) manquerait <P> et <SPAN>.
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
ExerciseExercice 13 not startedà faire solvedréussi keep tryingà retravailler
Test text: The chair, the cheese and the child are here.
Which expression finds exactly these highlighted words?
Texte de test : Le chat noir, le chien blanc et le cheval brun courent.
Quelle regex trouve exactement ces mots surlignés ?
Show the solutionVoir la solution
Answer: b) and d). ch\w+ and ch[aie]\w* both work. ch[aie] captures three letters only ("cha", "che", "chi"), and ch.+, being greedy, swallows everything to the end of the line.
Réponse : b) et d). ch\w+ et ch[aie]\w* fonctionnent tous les deux. ch[aie] ne capture que trois lettres (« cha », « chi », « che »), et ch.+, gourmand, avale tout jusqu'à la fin de la ligne.
ExerciseExercice 14 not startedà faire solvedréussi keep tryingà retravailler
Test text: There are 5 apples, 42 oranges, 123 bananas and 4567 seeds.
Which expression finds exactly these highlighted numbers?
Texte de test : Il y a 5 pommes, 42 oranges, 123 bananes et 4567 graines.
Quelle regex trouve exactement ces nombres surlignés ?
Show the solutionVoir la solution
Answer: b) and d). \d+ and [0-9]+ are equivalent. \d finds one digit at a time, and \d{1,3} would cut "4567" into "456" and "7".
Réponse : b) et d). \d+ et [0-9]+ sont équivalents. \d ne trouve qu'un chiffre à la fois, et \d{1,3} découperait « 4567 » en « 456 » et « 7 ».
ExerciseExercice 15 not startedà faire solvedréussi keep tryingà retravailler
Test text: Follow @mary and @john123 as well as @_test on social media.
Which expression finds exactly these highlighted mentions?
Texte de test : Suivez @marie et @jean123 ainsi que @_test sur les réseaux.
Quelle regex trouve exactement ces mentions surlignées ?
Show the solutionVoir la solution
Answer: a) and d). @\w+ and @[a-zA-Z0-9_]+ are equivalent: \w is exactly [a-zA-Z0-9_]. @[a-z]+ would miss the digits and the underscore; @.+ is far too greedy.
Réponse : a) et d). @\w+ et @[a-zA-Z0-9_]+ sont équivalents : \w est exactement [a-zA-Z0-9_]. @[a-z]+ manquerait les chiffres et le trait de soulignement ; @.+ est trop gourmand.
ExerciseExercice 16 not startedà faire solvedréussi keep tryingà retravailler
Test text: Postal codes: H3C 2K4 and V6B 1A1 are valid, but h3c 2k4 and 123 456 are not.
Which expression finds exactly these highlighted codes?
Texte de test : Codes postaux : H3C 2K4 et V6B 1A1 valides, mais h3c 2k4 et 123 456 sont invalides.
Quelle regex trouve exactement ces codes surlignés ?
Show the solutionVoir la solution
Answer: a). Only [A-Z]\d[A-Z] \d[A-Z]\d imposes the exact letter-digit sequence in capitals. b) and d) would accept the lowercase version ("h3c 2k4"), and c) would accept "123 456".
Réponse : a). Seule [A-Z]\d[A-Z] \d[A-Z]\d impose l'alternance exacte en majuscules. b) et d) accepteraient les minuscules (« h3c 2k4 »), et c) accepterait « 123 456 ».
ExerciseExercice 17 not startedà faire solvedréussi keep tryingà retravailler
Test text: Important dates: 01/12/2023 and 25/08/2024, but not 5/3/2025.
Which expression finds exactly these highlighted dates?
Texte de test : Dates importantes : 01/12/2023 et 25/08/2024, mais pas 5/3/2025.
Quelle regex trouve exactement ces dates surlignées ?
Show the solutionVoir la solution
Answer: a) and b). \d{2}/\d{2}/\d{4} is the idiomatic form; the long version gives the same matches. c) and d) would accept "5/3/2025" as well.
Réponse : a) et b). \d{2}/\d{2}/\d{4} est la forme idiomatique ; la version longue donne les mêmes correspondances. c) et d) accepteraient aussi « 5/3/2025 ».
ExerciseExercice 18 not startedà faire solvedréussi keep tryingà retravailler
Test text: URGENT: ABcd and WARNING are important.
Which expression finds exactly these highlighted words in capitals?
Texte de test : URGENT : ABcd et ATTENTION sont importants.
Quelle regex trouve exactement ces mots en majuscules surlignés ?
Show the solutionVoir la solution
Answer: c). \b[A-Z]+\b demands whole words in capitals. b) and d) would also capture "AB" inside "ABcd", with no word boundary to stop them.
Réponse : c). \b[A-Z]+\b exige des mots entiers en majuscules. b) et d) captureraient aussi « AB » dans « ABcd », sans limite de mot.
ExerciseExercice 19 not startedà faire solvedréussi keep tryingà retravailler
Test text: Prices: 15,99 €, 100,00 € and 2000,50 € (not 5,999 € or 50X99 €).
Which expression finds exactly these highlighted prices?
Texte de test : Prix : 15,99 €, 100,00 € et 2000,50 € (pas 5,999 € ni 50X99 €).
Quelle regex trouve exactement ces prix surlignés ?
Show the solutionVoir la solution
Answer: b). \d+,\d{2} € demands exactly two decimals. a) would accept "5,999 €"; c) would capture only "000,50 €" inside "2000,50 €"; d), with its unescaped dot, would also capture "50X99 €".
Réponse : b). \d+,\d{2} € exige exactement 2 décimales. a) accepterait « 5,999 € » ; c) ne capturerait que « 000,50 € » dans « 2000,50 € » ; d), avec son point non échappé, capturerait aussi « 50X99 € ».
ExerciseExercice 20 not startedà faire solvedréussi keep tryingà retravailler
Test text (French): Expressions: peut-être and week-end are common.
Which expression finds exactly these highlighted compounds?
Texte de test : Expressions : peut-être et week-end sont courantes.
Quelle regex trouve exactement ces mots composés surlignés ?
Show the solutionVoir la solution
Answer: b). \p{L} handles the "ê" of "peut-être". \w and [a-z] both fail on accents, and .+-.+ is far too permissive.
Réponse : b). \p{L} gère le « ê » de « peut-être ». \w et [a-z] échouent sur les accents, et .+-.+ est beaucoup trop permissif.
ExerciseExercice 21 not startedà faire solvedréussi keep tryingà retravailler
Test text: Abbreviations: Mr. Dupont and Dr. Martin in the text.
Which expression finds exactly these highlighted abbreviations?
Texte de test : Abréviations : M. Dupont et Dr. Martin dans le texte.
Quelle regex trouve exactement ces abréviations surlignées ?
Show the solutionVoir la solution
Answer: c). [A-Z][a-z]*\. accepts "Mr." and "Dr.". a) has an unescaped dot (a wildcard); b) fails on "Dr." (the r is lowercase); d) would also capture "text." at the end of the sentence.
Réponse : c). [A-Z][a-z]*\. accepte « M. » et « Dr. ». a) a un point non échappé (joker) ; b) échoue sur « Dr. » (le r est minuscule) ; d) capturerait aussi « texte. » en fin de phrase.
ExerciseExercice 22 not startedà faire solvedréussi keep tryingà retravailler
Test text: Percentages: 15%, 99.5% and 100% (not the incomplete 15.%).
Which expression finds exactly these highlighted percentages?
Texte de test : Pourcentages : 15%, 99,5% et 100% (pas 15.% incomplet).
Quelle regex trouve exactement ces pourcentages surlignés ?
Show the solutionVoir la solution
Answer: c). The optional group (\.\d+)? covers both cases. a) misses "99.5%"; b) demands a decimal part and misses "15%"; d) would also accept "15.%".
Réponse : c). Le groupe optionnel (,\d+)? couvre les deux cas. a) manque « 99,5% » ; b) exige une décimale et manque « 15% » ; d) accepterait aussi « 15.% ».
ExerciseExercice 23 not startedà faire solvedréussi keep tryingà retravailler
Test text: Websites: http://example.com and https://google.com are reachable.
Which expression finds exactly these highlighted URLs?
Texte de test : Sites web : http://example.com et https://google.com sont accessibles.
Quelle regex trouve exactement ces URL surlignées ?
Show the solutionVoir la solution
Answer: a) and d). https? and http[s]? both make the "s" optional, one with ? on a character, the other with an optional class.
Réponse : a) et d). https? et http[s]? rendent tous deux le « s » optionnel, l'un avec ? sur un caractère, l'autre avec une classe optionnelle.
ExerciseExercice 24 not startedà faire solvedréussi keep tryingà retravailler
Test text: HTML: <P>text</P> and <div>content</div> with <SPAN>element</SPAN>.
Which expression finds exactly these highlighted opening tags?
Texte de test : HTML : <P>texte</P> et <div>contenu</div> avec <SPAN>élément</SPAN>.
Quelle regex trouve exactement ces balises ouvrantes surlignées ?
Show the solutionVoir la solution
Answer: c). <\w+> captures the opening tags, capitals included. a) is greedy (one giant match), b) would capture the closing tags too, d) would miss <P> and <SPAN>.
Réponse : c). <\w+> capture les balises ouvrantes, majuscules comprises. a) est gourmande (une seule correspondance géante), b) capturerait aussi les balises fermantes, d) manquerait <P> et <SPAN>.
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

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.