Browse Explorer / Regular expressions Expressions rationnelles Regular expressions Expressions rationnelles Finding, cleaning and transforming text with patterns. Chercher, nettoyer et transformer du texte avec des motifs.
What to expect À quoi s'attendre An ordinary search looks for the exact words you typed. If you type "2024-12-25", you will find all occurrences of exactly those characters in that order. Regular expressions allow you to describe and search for patterns in text instead. So you could describe the date format: four digits, a hyphen, two digits, a hyphen, two digits. This will find "2024-12-25", but also any other date in that format, without you needing to list every date explicitly. The goal of this module is to teach the basics of regular expressions, i.e., enough to be able to read and create some common ones that may be useful in, e.g., translation practice. The module contains some eighty exercises in different formats, with automatic corrections and explanations, so you can practice as you progress. Une recherche ordinaire cherche exactement les caractères que vous avez tapés : « 2024-12-25 » trouve cette date et rien d'autre. Une expression rationnelle décrit plutôt le format : quatre chiffres, un tiret, deux chiffres, un tiret, deux chiffres. Elle trouve « 2024-12-25 » et toutes les autres dates dans ce format, sans avoir à les énumérer. Ce module enseigne les bases, assez pour lire et écrire les expressions qui servent dans la pratique de la traduction. Il contient quelque quatre-vingts exercices sous différents formats, avec corrections automatiques et explications, pour que vous puissiez vous entraîner à mesure que vous avancez.
Prerequisites Préalables You do not need to install anything, and you need no programming skills or knowledge from the other modules. If you have never programmed, this kind of “logical” thinking takes some patience, and it may not “click” immediately. At the start, the most important thing is to try the exercises: when you cannot solve one, take the time to understand its solution. Vous n'avez rien à installer, et vous n'avez besoin d'aucune compétence en programmation ni de notions tirées des autres modules. Si vous n'avez jamais programmé, ce type de raisonnement « logique » demande un peu de patience, et le déclic ne se fait pas forcément tout de suite. Au début, l'important est d'essayer de faire les exercices : quand vous n'arrivez pas à en résoudre un, prenez le temps de comprendre la solution.
Structure Structure The first chapter explains what a pattern is, what expressions are for in translation, why they are worth learning when a model will write one for you, and how to test one. The three middle chapters teach the syntax of regular expressions. There are exercises throughout all chapters, but the final chapter is where you will really get to practice and put everything together. Le premier chapitre explique ce qu'est un motif, à quoi servent les expressions rationnelles en traduction, pourquoi les apprendre quand un modèle en écrit une pour vous, et comment en tester une. Les trois chapitres du milieu enseignent la syntaxe des expressions rationnelles. Il y a des exercices dans tous les chapitres, mais c'est dans le dernier que vous pourrez vraiment vous entraîner et tout mettre ensemble.
Concepts in this module Les concepts de ce module alternation alternative alternation alternative regular expressions expressions rationnelles The either/or of a regular expression, written with a vertical bar: /cat|dog/ matches one or the other, and the first alternative that matches at that point is the one taken. Le « ou » d'une expression rationnelle, noté par une barre verticale : /chat|chien/ correspond à l'un ou à l'autre, et c'est la première possibilité qui correspond à cet endroit qui est retenue. · anchor ancre anchor ancre regular expressions expressions rationnelles A regular-expression construct that matches a position in the text rather than a character, so it makes a match succeed or fail without consuming anything. Construction d'expression rationnelle qui correspond à une position dans le texte plutôt qu'à un caractère : elle fait réussir ou échouer une correspondance sans rien consommer. · ASCII code ASCII ASCII code ASCII text encoding encodage du texte A 7-bit coded character set of 128 characters for information interchange, standardized as ANSI X3.4 and adopted as the US national variant of ISO/IEC 646. It holds the unaccented letters of the English alphabet, the digits, common punctuation and a set of control codes, and no accented letter. The first 128 characters of Unicode are the ASCII ones, in the same order, which is why UTF-8 stores them in a single byte. Jeu de caractères codés sur sept bits comptant 128 caractères, destiné à l'échange d'information, normalisé sous le nom ANSI X3.4 et repris comme variante nationale américaine de la norme ISO/IEC 646. Il contient les lettres non accentuées de l'alphabet anglais, les chiffres, la ponctuation courante et un ensemble de codes de commande, et aucune lettre accentuée. Les 128 premiers caractères d'Unicode sont ceux d'ASCII, dans le même ordre, ce qui explique qu'UTF-8 les stocke sur un seul octet. · capturing group groupe de capture capturing group groupe de capture regular expressions expressions rationnelles In a regular expression, a part of a pattern enclosed in parentheses, so that a quantifier or an alternation applies to the whole of it rather than to one character: /(ha)+/ repeats the pair, /(anti|pro)nuclear/ puts the choice inside the shared word. Dans une expression rationnelle, partie d'un motif placée entre parenthèses, pour qu'un quantificateur ou une alternative s'applique à l'ensemble plutôt qu'à un seul caractère : /(ha)+/ répète la paire, /(anti|pro)nucléaire/ place le choix à l'intérieur du mot commun. · character class classe de caractères character class classe de caractères regular expressions expressions rationnelles A regular-expression construct written in square brackets that matches exactly one character from the listed set or range, optionally negated with ^. Construction d'expression rationnelle entre crochets qui correspond à exactement un caractère parmi l'ensemble ou la plage indiquée, avec négation possible par ^. · collocation collocation collocation collocation corpora corpus A combination of words that co-occur more often than chance would predict and form a habitual, semi-fixed pairing, such as heavy rain or commit a crime (rather than strong rain or do a crime). Combinaison de mots qui apparaissent ensemble plus souvent que le hasard ne le laisserait prévoir et qui forment une association habituelle, semi-figée, comme soleil de plomb ou commettre un crime (plutôt que faire un crime). · corpus corpus corpus corpus corpora corpus A collection of written texts, speech recordings or transcribed language assembled for analysis or use in language technology (plural: corpora). Ensemble de textes écrits, d'enregistrements de parole ou de langue transcrite réuni pour l'analyse ou pour les technologies langagières. · flag drapeau flag drapeau regular expressions expressions rationnelles In programming, an option turned on or off for a whole operation, changing how it is executed. En programmation, option activée ou désactivée pour toute une opération, qui modifie sa façon de s'exécuter. · language model modèle de langue language model (LM) modèle de langue language models modèles de langue A machine-learning model that estimates how likely different sequences of language are. Modèle d'apprentissage automatique qui estime la probabilité de différentes séquences de langue. · line break saut de ligne line break saut de ligne text encoding encodage du texte The character that ends a line in a file, stored in it like any other and invisible on screen. It is what divides a file into lines, so a file's line count is fixed : two of them make three lines, whatever width the window is. Windows writes it as two characters, a carriage return followed by a line feed (CR LF), where macOS and Linux use one (LF). Caractère qui termine une ligne dans un fichier, enregistré comme n'importe quel autre et invisible à l'écran. C'est lui qui découpe le fichier en lignes, si bien que leur nombre est fixe : deux sauts de ligne font trois lignes, quelle que soit la largeur de la fenêtre. Windows l'écrit au moyen de deux caractères, un retour chariot suivi d'un saut de ligne (CR LF), là où macOS et Linux n'en emploient qu'un (LF). · metacharacter métacaractère metacharacter métacaractère regular expressions expressions rationnelles A character with a special meaning inside a regular expression (such as ., *, [ or ^) instead of matching itself literally; a backslash escape turns it back into a literal character. Caractère qui, dans une expression rationnelle, a une signification spéciale (comme ., *, [ ou ^) au lieu de se représenter lui-même ; une barre oblique inversée le ramène à sa valeur littérale. · operator precedence priorité des opérateurs operator precedence priorité des opérateurs computing informatique The rule fixing the order in which the operators of an expression are applied. In a regular expression that order runs from the quantifiers, which attach to the single element in front of them, through the elements written one after another, to the vertical bar, which has the lowest precedence of all and so separates everything on its left from everything on its right. Parentheses are applied before any of it, which is why /^(cat|dog)$/ and /^cat|dog$/ do not mean the same thing. Règle qui fixe l'ordre d'application des opérateurs d'une expression. Dans une expression rationnelle, cet ordre va des quantificateurs, qui portent sur le seul élément qui les précède, aux éléments écrits les uns à la suite des autres, puis à la barre verticale, dont la priorité est la plus faible et qui sépare donc tout ce qui est à sa gauche de tout ce qui est à sa droite. Les parenthèses s'appliquent avant tout cela, et c'est pourquoi /^(chat|chien)$/ et /^chat|chien$/ ne veulent pas dire la même chose. · quantifier quantificateur quantifier quantificateur regular expressions expressions rationnelles A regular-expression operator stating how many times the preceding element may repeat ({n}, {n,m}, *, +, ?); greedy by default, matching as much as possible, and made lazy with a following ? Opérateur d'expression rationnelle indiquant combien de fois l'élément précédent peut se répéter ({n}, {n,m}, *, +, ?); gourmand par défaut (il capture le plus possible), il devient non gourmand avec un ? supplémentaire. · regular expression expression rationnelle regular expression (regex) expression rationnelle regular expressions expressions rationnelles A pattern describing a set of character strings, built from literal characters and metacharacters with special meanings; used to search, filter and transform text by structure rather than by exact wording. Motif décrivant un ensemble de chaînes de caractères, formé de caractères littéraux et de métacaractères à signification spéciale; sert à chercher, filtrer et transformer du texte selon sa structure plutôt que selon une formulation exacte. · segmentation segmentation segmentation segmentation CAT tools TAO The operation of dividing translatable content into segments, which correspond roughly to sentences, titles and other separate text elements. Opération qui consiste à diviser le contenu à traduire en segments, qui correspondent plus ou moins aux phrases, aux titres et aux autres éléments textuels séparés. · tag balise tag balise markup balisage A marker that delimits and identifies an element in a markup document, usually working as a pair: an opening tag and a closing tag around the content they label. Marqueur qui délimite et identifie un élément dans un document balisé, fonctionnant généralement par paire : une balise ouvrante et une balise fermante autour du contenu qu'elles désignent. · wildcard caractère générique wildcard caractère générique regular expressions expressions rationnelles In a search, a character that stands for other characters rather than for itself, so the parts of a string that do not matter can be left unspecified. Dans une recherche, caractère qui tient lieu d'autres caractères plutôt que de lui-même, ce qui permet de laisser indéterminées les parties d'une chaîne dont on ne se soucie pas. · word boundary limite de mot word boundary limite de mot regular expressions expressions rationnelles The zero-width position between a word character and a non-word character, written \b in a regular expression; based on the ASCII \w set, so accented letters do not count as word characters. Position de largeur nulle entre un caractère de mot et un caractère qui n'en est pas un, notée \b dans une expression rationnelle; définie à partir de l'ensemble ASCII \w, si bien que les lettres accentuées ne comptent pas comme caractères de mot. alternation alternative alternation alternative regular expressions expressions rationnelles The either/or of a regular expression, written with a vertical bar: /cat|dog/ matches one or the other, and the first alternative that matches at that point is the one taken. Le « ou » d'une expression rationnelle, noté par une barre verticale : /chat|chien/ correspond à l'un ou à l'autre, et c'est la première possibilité qui correspond à cet endroit qui est retenue. · anchor ancre anchor ancre regular expressions expressions rationnelles A regular-expression construct that matches a position in the text rather than a character, so it makes a match succeed or fail without consuming anything. Construction d'expression rationnelle qui correspond à une position dans le texte plutôt qu'à un caractère : elle fait réussir ou échouer une correspondance sans rien consommer. · tag balise tag balise markup balisage A marker that delimits and identifies an element in a markup document, usually working as a pair: an opening tag and a closing tag around the content they label. Marqueur qui délimite et identifie un élément dans un document balisé, fonctionnant généralement par paire : une balise ouvrante et une balise fermante autour du contenu qu'elles désignent. · wildcard caractère générique wildcard caractère générique regular expressions expressions rationnelles In a search, a character that stands for other characters rather than for itself, so the parts of a string that do not matter can be left unspecified. Dans une recherche, caractère qui tient lieu d'autres caractères plutôt que de lui-même, ce qui permet de laisser indéterminées les parties d'une chaîne dont on ne se soucie pas. · character class classe de caractères character class classe de caractères regular expressions expressions rationnelles A regular-expression construct written in square brackets that matches exactly one character from the listed set or range, optionally negated with ^. Construction d'expression rationnelle entre crochets qui correspond à exactement un caractère parmi l'ensemble ou la plage indiquée, avec négation possible par ^. · ASCII code ASCII ASCII code ASCII text encoding encodage du texte A 7-bit coded character set of 128 characters for information interchange, standardized as ANSI X3.4 and adopted as the US national variant of ISO/IEC 646. It holds the unaccented letters of the English alphabet, the digits, common punctuation and a set of control codes, and no accented letter. The first 128 characters of Unicode are the ASCII ones, in the same order, which is why UTF-8 stores them in a single byte. Jeu de caractères codés sur sept bits comptant 128 caractères, destiné à l'échange d'information, normalisé sous le nom ANSI X3.4 et repris comme variante nationale américaine de la norme ISO/IEC 646. Il contient les lettres non accentuées de l'alphabet anglais, les chiffres, la ponctuation courante et un ensemble de codes de commande, et aucune lettre accentuée. Les 128 premiers caractères d'Unicode sont ceux d'ASCII, dans le même ordre, ce qui explique qu'UTF-8 les stocke sur un seul octet. · collocation collocation collocation collocation corpora corpus A combination of words that co-occur more often than chance would predict and form a habitual, semi-fixed pairing, such as heavy rain or commit a crime (rather than strong rain or do a crime). Combinaison de mots qui apparaissent ensemble plus souvent que le hasard ne le laisserait prévoir et qui forment une association habituelle, semi-figée, comme soleil de plomb ou commettre un crime (plutôt que faire un crime). · corpus corpus corpus corpus corpora corpus A collection of written texts, speech recordings or transcribed language assembled for analysis or use in language technology (plural: corpora). Ensemble de textes écrits, d'enregistrements de parole ou de langue transcrite réuni pour l'analyse ou pour les technologies langagières. · flag drapeau flag drapeau regular expressions expressions rationnelles In programming, an option turned on or off for a whole operation, changing how it is executed. En programmation, option activée ou désactivée pour toute une opération, qui modifie sa façon de s'exécuter. · regular expression expression rationnelle regular expression (regex) expression rationnelle regular expressions expressions rationnelles A pattern describing a set of character strings, built from literal characters and metacharacters with special meanings; used to search, filter and transform text by structure rather than by exact wording. Motif décrivant un ensemble de chaînes de caractères, formé de caractères littéraux et de métacaractères à signification spéciale; sert à chercher, filtrer et transformer du texte selon sa structure plutôt que selon une formulation exacte. · capturing group groupe de capture capturing group groupe de capture regular expressions expressions rationnelles In a regular expression, a part of a pattern enclosed in parentheses, so that a quantifier or an alternation applies to the whole of it rather than to one character: /(ha)+/ repeats the pair, /(anti|pro)nuclear/ puts the choice inside the shared word. Dans une expression rationnelle, partie d'un motif placée entre parenthèses, pour qu'un quantificateur ou une alternative s'applique à l'ensemble plutôt qu'à un seul caractère : /(ha)+/ répète la paire, /(anti|pro)nucléaire/ place le choix à l'intérieur du mot commun. · word boundary limite de mot word boundary limite de mot regular expressions expressions rationnelles The zero-width position between a word character and a non-word character, written \b in a regular expression; based on the ASCII \w set, so accented letters do not count as word characters. Position de largeur nulle entre un caractère de mot et un caractère qui n'en est pas un, notée \b dans une expression rationnelle; définie à partir de l'ensemble ASCII \w, si bien que les lettres accentuées ne comptent pas comme caractères de mot. · metacharacter métacaractère metacharacter métacaractère regular expressions expressions rationnelles A character with a special meaning inside a regular expression (such as ., *, [ or ^) instead of matching itself literally; a backslash escape turns it back into a literal character. Caractère qui, dans une expression rationnelle, a une signification spéciale (comme ., *, [ ou ^) au lieu de se représenter lui-même ; une barre oblique inversée le ramène à sa valeur littérale. · language model modèle de langue language model (LM) modèle de langue language models modèles de langue A machine-learning model that estimates how likely different sequences of language are. Modèle d'apprentissage automatique qui estime la probabilité de différentes séquences de langue. · operator precedence priorité des opérateurs operator precedence priorité des opérateurs computing informatique The rule fixing the order in which the operators of an expression are applied. In a regular expression that order runs from the quantifiers, which attach to the single element in front of them, through the elements written one after another, to the vertical bar, which has the lowest precedence of all and so separates everything on its left from everything on its right. Parentheses are applied before any of it, which is why /^(cat|dog)$/ and /^cat|dog$/ do not mean the same thing. Règle qui fixe l'ordre d'application des opérateurs d'une expression. Dans une expression rationnelle, cet ordre va des quantificateurs, qui portent sur le seul élément qui les précède, aux éléments écrits les uns à la suite des autres, puis à la barre verticale, dont la priorité est la plus faible et qui sépare donc tout ce qui est à sa gauche de tout ce qui est à sa droite. Les parenthèses s'appliquent avant tout cela, et c'est pourquoi /^(chat|chien)$/ et /^chat|chien$/ ne veulent pas dire la même chose. · quantifier quantificateur quantifier quantificateur regular expressions expressions rationnelles A regular-expression operator stating how many times the preceding element may repeat ({n}, {n,m}, *, +, ?); greedy by default, matching as much as possible, and made lazy with a following ? Opérateur d'expression rationnelle indiquant combien de fois l'élément précédent peut se répéter ({n}, {n,m}, *, +, ?); gourmand par défaut (il capture le plus possible), il devient non gourmand avec un ? supplémentaire. · line break saut de ligne line break saut de ligne text encoding encodage du texte The character that ends a line in a file, stored in it like any other and invisible on screen. It is what divides a file into lines, so a file's line count is fixed : two of them make three lines, whatever width the window is. Windows writes it as two characters, a carriage return followed by a line feed (CR LF), where macOS and Linux use one (LF). Caractère qui termine une ligne dans un fichier, enregistré comme n'importe quel autre et invisible à l'écran. C'est lui qui découpe le fichier en lignes, si bien que leur nombre est fixe : deux sauts de ligne font trois lignes, quelle que soit la largeur de la fenêtre. Windows l'écrit au moyen de deux caractères, un retour chariot suivi d'un saut de ligne (CR LF), là où macOS et Linux n'en emploient qu'un (LF). · segmentation segmentation segmentation segmentation CAT tools TAO The operation of dividing translatable content into segments, which correspond roughly to sentences, titles and other separate text elements. Opération qui consiste à diviser le contenu à traduire en segments, qui correspondent plus ou moins aux phrases, aux titres et aux autres éléments textuels séparés.