Administrator
This teaching view is for the instructor. Enter the administrator password.
Wrong password · Mot de passe incorrect
Key pointsL'essentiel
Describing positionsDécrire des positions
Anchors and word boundaries match no character at all: they mark a position between two characters.
Les ancres et les limites de mot ne correspondent à aucun caractère : elles marquent une position entre deux caractères.
Key pointsL'essentiel
Describing positionsDécrire des positions
^ and $ mark the start and the end of a line; with the m flag each line counts for itself, and /^$/ finds the empty lines.
^ et $ marquent le début et la fin d'une ligne ; avec le drapeau m, chaque ligne compte pour elle-même, et /^$/ trouve les lignes vides.
Key pointsL'essentiel
Describing positionsDécrire des positions
The \b sits between a word character and a character that is not one; it is defined in terms of \w, and so in terms of ASCII.
La \b sépare un caractère de mot d'un caractère qui n'en est pas un ; elle se définit à partir de \w, donc à partir de l'ASCII.
Key pointsL'essentiel
Describing positionsDécrire des positions
On accented French, \b gets it wrong: « été » is not found and « très » yields « trè ».
Sur du français accentué, \b se trompe : « été » n'est pas trouvé et « très » donne « trè ».
Page 1Page 1
Line anchorsLes ancres de ligne
- Anchors do not match characters; they match positions: ^ marks the start of a line, $ the end.
- With the m (on throughout the module), each line is treated on its own.
- So ^ has two roles depending on context: the start-of-line anchor, or negation at the head of a class [^...].
- Empty lines can be matched using /^$/: two anchors with nothing between them.
- Les ancres ne correspondent pas à des caractères, mais à des positions : ^ marque le début d'une ligne, $ la fin.
- Avec le m (actif dans tout le module), chaque ligne est traitée indépendamment.
- ^ a donc deux rôles selon le contexte : ancre de début de ligne, ou négation en tête d'une classe [^...].
- Les lignes vides se trouvent avec /^$/ : deux ancres sans rien entre elles.
Page 2Page 2
The word boundaryLa limite de mot
- \b marks a : the position between a "word" character and a character that is not one.
- Like the , \b consumes no character: /\bcat\b/ finds "cat" on its own, not "catalogue" or "bobcat".
- "Word" means \w here, so unaccented letters only.
- \b marque une : la position entre un caractère « de mot » et un caractère qui n'en est pas un.
- Comme les , \b ne consomme aucun caractère : /\bchat\b/ trouve « chat » seul, pas « chatouiller » ni « achat ».
- « Mot » veut dire \w ici, donc uniquement des lettres non accentuées.
Page 3Page 3
\b and accented letters\b et les lettres accentuées
- \b is defined from \w, which contains no accented letter, and the u does not change that.
- So \b falls in the wrong places in French: it finds no start of word in front of "été", and it finds a boundary in the middle of "très".
- Where accents matter, delimit with explicit spaces or punctuation rather than with \b.
- \b se définit à partir de \w, qui ne contient aucune lettre accentuée, et le u n'y change rien.
- \b tombe donc au mauvais endroit en français : il ne trouve pas de début de mot devant « été », et il trouve une limite au milieu de « très ».
- Quand les accents comptent, délimitez avec des espaces ou de la ponctuation explicites plutôt qu'avec \b.