Shorthand quantifiers: *, +, ?Quantificateurs abrégés : *, +, ?
The most frequent repetitions have a symbol of their own:
| Symbol | Equivalent | Meaning |
|---|---|---|
* | {0,} | 0 or more |
+ | {1,} | 1 or more |
? | {0,1} | 0 or 1 (optional) |
Examples:
colou?r→ “color” or “colour”: the “u” is optional;\d+→ one or more digits;\s*→ zero or more whitespace characters.
The ? deserves particular attention: it is the one that describes a
variation, and a spelling variation is exactly what a language professional
spends time looking for. A doubled letter or not, an optional accent, a plural
“s”, a British spelling against an American one.
Find "color" and "colour" (the American and British spellings) in one expression.
Trouvez « color » et « colour » (orthographes américaine et britannique) en une seule expression.
Test textTexte de test
The color of the flag is red. The colour of the sky is blue. I prefer colorful pictures over colourful ones. The colony and the column are different.The color of the flag is red. The colour of the sky is blue. I prefer colorful pictures over colourful ones. The colony and the column are different. Expected matches:Correspondances attendues :
color colour color colour Expected matches:Correspondances attendues :
color colour color colour //gmu
Find the word "address", spelled correctly (two d's) or with the common mistake (one d), but not the variants with three d's or more.
Trouvez le mot « adresse », bien orthographié (deux s) ou avec la faute courante (un seul s), mais pas les variantes à 3 s ou plus.
Test textTexte de test
Here is my full address. I have a temporary adress. The postal address and the email adress are different. Beware of the adddress with three d's.Voici mon adresse complète. J'ai une adrese temporaire. L'adresse postale et l'adrese courriel sont différentes. Attention à l'adresssse avec 4 s. Expected matches:Correspondances attendues :
adresse adrese adresse adrese Expected matches:Correspondances attendues :
address adress address adress //gmu
Find every run of digits, whatever its length.
Trouvez toutes les suites de chiffres, quelle que soit leur longueur.
Test textTexte de test
I ordered 3 books, 15 pens and 127 sheets of paper, but it took me 3462814235413 hours! The price is 12.50$.J'ai commandé 3 livres, 15 stylos et 127 feuilles de papier, mais ça m'a pris 3462814235413 heures! Le prix est 12.50$. Expected matches:Correspondances attendues :
3 15 127 3462814235413 12 50 Expected matches:Correspondances attendues :
3 15 127 3462814235413 12 50 //gmu
Find the runs of at least 2 consecutive punctuation marks (
. ! ?).Trouvez les séquences d'au moins 2 signes de ponctuation consécutifs (
. ! ?).Test textTexte de test
That is amazing!!! Really??? Wait... No! Yes. Maybe? Absolutely!! Ellipsis... And!? really?!C'est incroyable!!! Vraiment??? Attendez... Non! Oui. Peut-être? Absolument!! Points de suspension... Et!? vraiment?! Expected matches:Correspondances attendues :
!!! ??? ... !! ... !? ?! Expected matches:Correspondances attendues :
!!! ??? ... !! ... !? ?! //gmu
Find the runs of 2 whitespace characters or more (useful for cleaning up formatting).
Trouvez les séquences de 2 blancs ou plus (utile pour nettoyer la mise en forme).
Test textTexte de test
Here is a text with multiple spaces. But not here. One only here too.Voici un texte avec des espaces multiples. Mais pas ici. Un seul ici aussi. 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
Find the URL openings "http://" and "https://" (not the other protocols).
Trouvez les débuts d'URL « http:// » et « https:// » (pas les autres protocoles).
Test textTexte de test
Visit http://example.com or https://secure.com for more. The ftp:// protocol is not included. Nor file://local nor mailto:test@test.com.Visitez http://example.com ou https://secure.com pour plus d'infos. Le protocole ftp:// n'est pas inclus. Ni file://local ni mailto:test@test.com. Expected matches:Correspondances attendues :
http:// https:// Expected matches:Correspondances attendues :
http:// https:// //gmu
Les cas de répétition les plus fréquents ont leur symbole dédié :
| Symbole | Équivalent | Signification |
|---|---|---|
* | {0,} | 0 ou plus |
+ | {1,} | 1 ou plus |
? | {0,1} | 0 ou 1 (optionnel) |
Exemples :
colou?r→ « color » ou « colour » : le « u » est optionnel ;\d+→ un ou plusieurs chiffres ;\s*→ zéro ou plusieurs blancs.
Le ? mérite une attention particulière : c’est lui qui décrit une variation,
et une variation orthographique est exactement ce qu’un langagier passe son
temps à chercher. Une lettre doublée ou non, un accent facultatif, un
« s » de pluriel, une graphie britannique et une américaine.
Find "color" and "colour" (the American and British spellings) in one expression.
Trouvez « color » et « colour » (orthographes américaine et britannique) en une seule expression.
Test textTexte de test
The color of the flag is red. The colour of the sky is blue. I prefer colorful pictures over colourful ones. The colony and the column are different.The color of the flag is red. The colour of the sky is blue. I prefer colorful pictures over colourful ones. The colony and the column are different. Expected matches:Correspondances attendues :
color colour color colour Expected matches:Correspondances attendues :
color colour color colour //gmu
Find the word "address", spelled correctly (two d's) or with the common mistake (one d), but not the variants with three d's or more.
Trouvez le mot « adresse », bien orthographié (deux s) ou avec la faute courante (un seul s), mais pas les variantes à 3 s ou plus.
Test textTexte de test
Here is my full address. I have a temporary adress. The postal address and the email adress are different. Beware of the adddress with three d's.Voici mon adresse complète. J'ai une adrese temporaire. L'adresse postale et l'adrese courriel sont différentes. Attention à l'adresssse avec 4 s. Expected matches:Correspondances attendues :
adresse adrese adresse adrese Expected matches:Correspondances attendues :
address adress address adress //gmu
Find every run of digits, whatever its length.
Trouvez toutes les suites de chiffres, quelle que soit leur longueur.
Test textTexte de test
I ordered 3 books, 15 pens and 127 sheets of paper, but it took me 3462814235413 hours! The price is 12.50$.J'ai commandé 3 livres, 15 stylos et 127 feuilles de papier, mais ça m'a pris 3462814235413 heures! Le prix est 12.50$. Expected matches:Correspondances attendues :
3 15 127 3462814235413 12 50 Expected matches:Correspondances attendues :
3 15 127 3462814235413 12 50 //gmu
Find the runs of at least 2 consecutive punctuation marks (
. ! ?).Trouvez les séquences d'au moins 2 signes de ponctuation consécutifs (
. ! ?).Test textTexte de test
That is amazing!!! Really??? Wait... No! Yes. Maybe? Absolutely!! Ellipsis... And!? really?!C'est incroyable!!! Vraiment??? Attendez... Non! Oui. Peut-être? Absolument!! Points de suspension... Et!? vraiment?! Expected matches:Correspondances attendues :
!!! ??? ... !! ... !? ?! Expected matches:Correspondances attendues :
!!! ??? ... !! ... !? ?! //gmu
Find the runs of 2 whitespace characters or more (useful for cleaning up formatting).
Trouvez les séquences de 2 blancs ou plus (utile pour nettoyer la mise en forme).
Test textTexte de test
Here is a text with multiple spaces. But not here. One only here too.Voici un texte avec des espaces multiples. Mais pas ici. Un seul ici aussi. 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
Find the URL openings "http://" and "https://" (not the other protocols).
Trouvez les débuts d'URL « http:// » et « https:// » (pas les autres protocoles).
Test textTexte de test
Visit http://example.com or https://secure.com for more. The ftp:// protocol is not included. Nor file://local nor mailto:test@test.com.Visitez http://example.com ou https://secure.com pour plus d'infos. Le protocole ftp:// n'est pas inclus. Ni file://local ni mailto:test@test.com. Expected matches:Correspondances attendues :
http:// https:// Expected matches:Correspondances attendues :
http:// https:// //gmu
Sources
- MDN Web Docs (n.d.). Regular expressions. MDN JavaScript Guide, Mozilla. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
Sources
- MDN Web Docs (n.d.). Regular expressions. MDN JavaScript Guide, Mozilla. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions