python-docs-fr/howto/regex.po

2197 lines
89 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright (C) 2001-2018, Python Software Foundation
# For licence information, see README file.
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.6\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-28 15:29+0200\n"
"PO-Revision-Date: 2018-07-24 00:09+0200\n"
"Last-Translator: Nabil Bendafi <nabil@bendafi.fr>\n"
"Language-Team: FRENCH <traductions@lists.afpy.org>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.2\n"
#: ../Doc/howto/regex.rst:5
msgid "Regular Expression HOWTO"
msgstr "Guide des expressions régulières"
#: ../Doc/howto/regex.rst:0
msgid "Author"
msgstr "Auteur"
#: ../Doc/howto/regex.rst:7
msgid "A.M. Kuchling <amk@amk.ca>"
msgstr "A.M. Kuchling <amk@amk.ca>"
#: ../Doc/howto/regex.rst:None
msgid "Abstract"
msgstr "Résumé"
#: ../Doc/howto/regex.rst:18
msgid ""
"This document is an introductory tutorial to using regular expressions in "
"Python with the :mod:`re` module. It provides a gentler introduction than "
"the corresponding section in the Library Reference."
msgstr ""
"Ce document constitue un guide d'introduction à l'utilisation des "
"expressions régulières en Python avec le module :mod:`re`. Il fournit une "
"introduction plus abordable que la section correspondante dans le guide de "
"référence de la bibliothèque."
#: ../Doc/howto/regex.rst:24
msgid "Introduction"
msgstr "Introduction"
#: ../Doc/howto/regex.rst:26
msgid ""
"Regular expressions (called REs, or regexes, or regex patterns) are "
"essentially a tiny, highly specialized programming language embedded inside "
"Python and made available through the :mod:`re` module. Using this little "
"language, you specify the rules for the set of possible strings that you "
"want to match; this set might contain English sentences, or e-mail "
"addresses, or TeX commands, or anything you like. You can then ask "
"questions such as \"Does this string match the pattern?\", or \"Is there a "
"match for the pattern anywhere in this string?\". You can also use REs to "
"modify a string or to split it apart in various ways."
msgstr ""
"Les expressions régulières (notées RE ou motifs regex dans ce document) sont "
"essentiellement un petit langage de programmation hautement spécialisé "
"embarqué dans Python et dont la manipulation est rendue possible par "
"l'utilisation du module :mod:`re`. En utilisant ce petit langage, vous "
"définissez des règles pour spécifier une correspondance avec un ensemble "
"souhaité de chaînes de caractères ; ces chaînes peuvent être des phrases, "
"des adresses de courriel, des commandes TeX ou tout ce que vous voulez. Vous "
"pouvez ensuite poser des questions telles que \"Est-ce que cette chaîne de "
"caractères correspond au motif ?\" ou \"Y-a-t'il une correspondance pour ce "
"motif à l'intérieur de la chaîne de caractères ?\". Vous pouvez aussi "
"utiliser les RE pour modifier une chaîne de caractères ou la découper de "
"différentes façons."
#: ../Doc/howto/regex.rst:35
msgid ""
"Regular expression patterns are compiled into a series of bytecodes which "
"are then executed by a matching engine written in C. For advanced use, it "
"may be necessary to pay careful attention to how the engine will execute a "
"given RE, and write the RE in a certain way in order to produce bytecode "
"that runs faster. Optimization isn't covered in this document, because it "
"requires that you have a good understanding of the matching engine's "
"internals."
msgstr ""
"Un motif d'expression régulière est compilé en **bytecode** qui est ensuite "
"exécuté par un moteur de correspondance écrit en C. Pour une utilisation "
"plus poussée, il peut s'avérer nécessaire de s'intéresser à la manière dont "
"le moteur exécute la RE afin d'écrire une expression dont le **bytecode** "
"est plus rapide. L'optimisation n'est pas traitée dans ce document, parce "
"qu'elle nécessite d'avoir une bonne compréhension des mécanismes internes du "
"moteur de correspondance."
#: ../Doc/howto/regex.rst:42
msgid ""
"The regular expression language is relatively small and restricted, so not "
"all possible string processing tasks can be done using regular expressions. "
"There are also tasks that *can* be done with regular expressions, but the "
"expressions turn out to be very complicated. In these cases, you may be "
"better off writing Python code to do the processing; while Python code will "
"be slower than an elaborate regular expression, it will also probably be "
"more understandable."
msgstr ""
"Le langage des expressions régulières est relativement petit et restreint, "
"donc toutes les tâches de manipulation de chaînes de caractères ne peuvent "
"pas être réalisées à l'aide d'expressions régulières. Il existe aussi des "
"tâches qui *peuvent* être réalisées à l'aide d'expressions régulières mais "
"qui ont tendance à produire des expressions régulières très compliquées. "
"Dans ces cas, il est plus utile d'écrire du code Python pour réaliser le "
"traitement ; même si le code Python est plus lent qu'une expression "
"régulière élaborée, il sera probablement plus compréhensible."
#: ../Doc/howto/regex.rst:51
msgid "Simple Patterns"
msgstr "Motifs simples"
#: ../Doc/howto/regex.rst:53
msgid ""
"We'll start by learning about the simplest possible regular expressions. "
"Since regular expressions are used to operate on strings, we'll begin with "
"the most common task: matching characters."
msgstr ""
"Nous commençons par étudier les expressions régulières les plus simples. "
"Dans la mesure où les expressions régulières sont utilisées pour manipuler "
"des chaînes de caractères, nous commençons par l'action la plus courante : "
"la correspondance de caractères."
#: ../Doc/howto/regex.rst:57
msgid ""
"For a detailed explanation of the computer science underlying regular "
"expressions (deterministic and non-deterministic finite automata), you can "
"refer to almost any textbook on writing compilers."
msgstr ""
"Pour une explication détaillée sur le concept informatique sous-jacent aux "
"expressions régulières (automate à états déterministe ou non-déterministe), "
"vous pouvez vous référer à n'importe quel manuel sur l'écriture de "
"compilateurs."
#: ../Doc/howto/regex.rst:63
msgid "Matching Characters"
msgstr "Correspondance de caractères"
#: ../Doc/howto/regex.rst:65
msgid ""
"Most letters and characters will simply match themselves. For example, the "
"regular expression ``test`` will match the string ``test`` exactly. (You "
"can enable a case-insensitive mode that would let this RE match ``Test`` or "
"``TEST`` as well; more about this later.)"
msgstr ""
"La plupart des lettres ou caractères correspondent simplement à eux-mêmes. "
"Par exemple, l'expression régulière ``test`` correspond à la chaîne de "
"caractères ``test``, précisément. Vous pouvez activer le mode non-sensible à "
"la casse qui permet à cette RE de correspondre également à ``Test`` ou "
"``TEST`` (ce sujet est traité par la suite)."
#: ../Doc/howto/regex.rst:70
msgid ""
"There are exceptions to this rule; some characters are special :dfn:"
"`metacharacters`, and don't match themselves. Instead, they signal that "
"some out-of-the-ordinary thing should be matched, or they affect other "
"portions of the RE by repeating them or changing their meaning. Much of "
"this document is devoted to discussing various metacharacters and what they "
"do."
msgstr ""
"Il existe des exceptions à cette règle ; certains caractères sont des :dfn:"
"`métacaractères` spéciaux et ne correspondent pas à eux-mêmes. Au lieu de "
"cela, ils signalent que certaines choses non ordinaires doivent "
"correspondre, ou ils affectent d'autre portions de la RE en les répétant ou "
"en changeant leur sens. Une grande partie de ce document est consacrée au "
"fonctionnement de ces métacaractères."
#: ../Doc/howto/regex.rst:76
msgid ""
"Here's a complete list of the metacharacters; their meanings will be "
"discussed in the rest of this HOWTO."
msgstr ""
"Voici une liste complète des métacaractères ; leur sens est décrit dans la "
"suite de ce guide."
#: ../Doc/howto/regex.rst:83
msgid ""
"The first metacharacters we'll look at are ``[`` and ``]``. They're used for "
"specifying a character class, which is a set of characters that you wish to "
"match. Characters can be listed individually, or a range of characters can "
"be indicated by giving two characters and separating them by a ``'-'``. For "
"example, ``[abc]`` will match any of the characters ``a``, ``b``, or ``c``; "
"this is the same as ``[a-c]``, which uses a range to express the same set of "
"characters. If you wanted to match only lowercase letters, your RE would be "
"``[a-z]``."
msgstr ""
"Les premiers métacaractères que nous étudions sont ``[`` et ``]``. Ils sont "
"utilisés pour spécifier une classe de caractères, qui forme un ensemble de "
"caractères dont vous souhaitez trouver la correspondance. Les caractères "
"peuvent être listés individuellement, ou une plage de caractères peut être "
"indiquée en fournissant deux caractères séparés par un `'-'``. Par exemple, "
"``[abc]`` correspond à n'importe quel caractère parmi ``a``, ``b``, ou "
"``c`` ; c'est équivalent à ``[a-c]``, qui utilise une plage pour exprimer le "
"même ensemble de caractères. Si vous voulez trouver une chaîne qui ne "
"contient que des lettres en minuscules, la RE est ``[a-z]``."
#: ../Doc/howto/regex.rst:92
msgid ""
"Metacharacters are not active inside classes. For example, ``[akm$]`` will "
"match any of the characters ``'a'``, ``'k'``, ``'m'``, or ``'$'``; ``'$'`` "
"is usually a metacharacter, but inside a character class it's stripped of "
"its special nature."
msgstr ""
"Les métacaractères ne sont pas actifs dans les classes. Par exemple, ``[akm"
"$]`` correspond à n'importe quel caractère parmi ``'a'``, ``'k'``, ``'m'`` "
"ou ``'$'`` ; ``'$'`` est habituellement un métacaractère mais dans une "
"classe de caractères, il est dépourvu de sa signification spéciale."
#: ../Doc/howto/regex.rst:97
msgid ""
"You can match the characters not listed within the class by :dfn:"
"`complementing` the set. This is indicated by including a ``'^'`` as the "
"first character of the class; ``'^'`` outside a character class will simply "
"match the ``'^'`` character. For example, ``[^5]`` will match any character "
"except ``'5'``."
msgstr ""
"Vous pouvez trouver une correspondance avec les caractères non listés dans "
"une classe en spécifiant le :dfn:`complément` de l'ensemble. Ceci est "
"indiqué en plaçant un ``'^'`` en tant que premier caractère de la classe ; "
"``'^'`` en dehors d'une classe de caractères correspond au caractère "
"``'^'``. Par exemple, ``[^5]`` correspond à tous les caractères, sauf "
"``'5'``."
#: ../Doc/howto/regex.rst:102
msgid ""
"Perhaps the most important metacharacter is the backslash, ``\\``. As in "
"Python string literals, the backslash can be followed by various characters "
"to signal various special sequences. It's also used to escape all the "
"metacharacters so you can still match them in patterns; for example, if you "
"need to match a ``[`` or ``\\``, you can precede them with a backslash to "
"remove their special meaning: ``\\[`` or ``\\\\``."
msgstr ""
"Le métacaractère probablement le plus important est la barre oblique inverse "
"( *backslash* en anglais), ``\\``. Comme dans les chaînes de caractères en "
"Python, la barre oblique inverse peut être suivie par différents caractères "
"pour signaler différentes séquences spéciales. Elle est aussi utilisée pour "
"échapper tous les métacaractères afin d'en trouver les correspondances dans "
"les motifs ; par exemple, si vous devez trouver une correspondance pour "
"``[`` ou ``\\`, vous pouvez les précéder avec une barre oblique inverse pour "
"annihiler leur signification spéciale : ``\\[`` ou ``\\\\``."
#: ../Doc/howto/regex.rst:109
msgid ""
"Some of the special sequences beginning with ``'\\'`` represent predefined "
"sets of characters that are often useful, such as the set of digits, the set "
"of letters, or the set of anything that isn't whitespace."
msgstr ""
"Certaines séquences spéciales commençant par ``'\\'`` représentent des "
"ensembles de caractères prédéfinis qui sont souvent utiles, tels que "
"l'ensemble des chiffres, l'ensemble des lettres ou l'ensemble des caractères "
"qui ne sont pas des \"blancs\"."
#: ../Doc/howto/regex.rst:114
msgid ""
"Let's take an example: ``\\w`` matches any alphanumeric character. If the "
"regex pattern is expressed in bytes, this is equivalent to the class ``[a-zA-"
"Z0-9_]``. If the regex pattern is a string, ``\\w`` will match all the "
"characters marked as letters in the Unicode database provided by the :mod:"
"`unicodedata` module. You can use the more restricted definition of ``\\w`` "
"in a string pattern by supplying the :const:`re.ASCII` flag when compiling "
"the regular expression."
msgstr ""
"Prenons un exemple : ``\\w`` correspond à n'importe quel caractère "
"alphanumérique. Si l'expression régulière est exprimée en *bytes*, c'est "
"équivalent à la classe ``[a-zA-Z0-9_]``. Si l'expression régulière est une "
"chaîne de caractères, ``\\w`` correspond à tous les caractères identifiés "
"comme lettre dans la base de données Unicode fournie par le module :mod:"
"`unicodedata`. Vous pouvez utiliser la définition plus restrictive de ``"
"\\w`` dans un motif exprimé en chaîne de caractères en spécifiant l'option :"
"const:`re.ASCII` lors de la compilation de l'expression régulière."
#: ../Doc/howto/regex.rst:122
msgid ""
"The following list of special sequences isn't complete. For a complete list "
"of sequences and expanded class definitions for Unicode string patterns, see "
"the last part of :ref:`Regular Expression Syntax <re-syntax>` in the "
"Standard Library reference. In general, the Unicode versions match any "
"character that's in the appropriate category in the Unicode database."
msgstr ""
"La liste de séquences spéciales suivante est incomplète. Pour une liste "
"complète des séquences et définitions de classes étendues relatives aux "
"motifs de chaînes de caractères Unicode, reportez-vous à la dernière partie "
"de la référence :ref:`Syntaxe d'Expressions Régulières <re-syntax>` de la "
"bibliothèque standard. En général, les versions Unicode trouvent une "
"correspondance avec n'importe quel caractère présent dans la catégorie "
"appropriée de la base de données Unicode."
#: ../Doc/howto/regex.rst:130
msgid "``\\d``"
msgstr "``\\d``"
#: ../Doc/howto/regex.rst:130
msgid "Matches any decimal digit; this is equivalent to the class ``[0-9]``."
msgstr ""
"Correspond à n'importe quel caractère numérique ; équivalent à la classe "
"``[0-9]``."
#: ../Doc/howto/regex.rst:133
msgid "``\\D``"
msgstr "``\\D``"
#: ../Doc/howto/regex.rst:133
msgid ""
"Matches any non-digit character; this is equivalent to the class ``[^0-9]``."
msgstr ""
"Correspond à n'importe caractère non numérique ; équivalent à la classe "
"``[^0-9]``."
#: ../Doc/howto/regex.rst:137
msgid "``\\s``"
msgstr "``\\s``"
#: ../Doc/howto/regex.rst:136
msgid ""
"Matches any whitespace character; this is equivalent to the class ``[ \\t\\n"
"\\r\\f\\v]``."
msgstr ""
"Correspond à n'importe quel caractère \"blanc\" ; équivalent à la classe "
"``[ \\t\\n\\r\\f\\v]``."
#: ../Doc/howto/regex.rst:141
msgid "``\\S``"
msgstr "``\\S``"
#: ../Doc/howto/regex.rst:140
msgid ""
"Matches any non-whitespace character; this is equivalent to the class ``[^ "
"\\t\\n\\r\\f\\v]``."
msgstr ""
"Correspond à n'importe caractère autre que \"blanc\" ; équivalent à la "
"classe ``[^ \\t\\n\\r\\f\\v]``."
#: ../Doc/howto/regex.rst:145
msgid "``\\w``"
msgstr "``\\w``"
#: ../Doc/howto/regex.rst:144
msgid ""
"Matches any alphanumeric character; this is equivalent to the class ``[a-zA-"
"Z0-9_]``."
msgstr ""
"Correspond à n'importe caractère alphanumérique ; équivalent à la classe "
"``[a-zA-Z0-9_]``."
#: ../Doc/howto/regex.rst:149
msgid "``\\W``"
msgstr "``\\W``"
#: ../Doc/howto/regex.rst:148
msgid ""
"Matches any non-alphanumeric character; this is equivalent to the class "
"``[^a-zA-Z0-9_]``."
msgstr ""
"Correspond à n'importe caractère non-alphanumérique ; équivalent à la classe "
"``[^a-zA-Z0-9_]``."
#: ../Doc/howto/regex.rst:151
msgid ""
"These sequences can be included inside a character class. For example, "
"``[\\s,.]`` is a character class that will match any whitespace character, "
"or ``','`` or ``'.'``."
msgstr ""
"Ces séquences peuvent être incluses dans une classe de caractères. Par "
"exemple, ``[\\s,.]`` est une classe de caractères qui correspond à tous les "
"caractères \"blancs\" ou ``','`` ou ``'.'``."
#: ../Doc/howto/regex.rst:155
msgid ""
"The final metacharacter in this section is ``.``. It matches anything "
"except a newline character, and there's an alternate mode (:const:`re."
"DOTALL`) where it will match even a newline. ``.`` is often used where you "
"want to match \"any character\"."
msgstr ""
"Le dernier métacaractère de cette section est ``.``. Il correspond à tous "
"les caractères, à l'exception du caractère de retour à la ligne ; il existe "
"un mode alternatif (:const:`re.DOTALL`) dans lequel il correspond également "
"eu caractère de retour à la ligne. ``.`` est souvent utilisé lorsque l'on "
"veut trouver une correspondance avec \"n'importe quel caractère\"."
#: ../Doc/howto/regex.rst:162
msgid "Repeating Things"
msgstr "Répétitions"
#: ../Doc/howto/regex.rst:164
msgid ""
"Being able to match varying sets of characters is the first thing regular "
"expressions can do that isn't already possible with the methods available on "
"strings. However, if that was the only additional capability of regexes, "
"they wouldn't be much of an advance. Another capability is that you can "
"specify that portions of the RE must be repeated a certain number of times."
msgstr ""
"Trouver des correspondances de divers ensembles de caractères est la "
"première utilisation des expressions régulières, ce que l'on ne peut pas "
"faire avec les méthodes des chaînes. Cependant, si c'était la seule "
"possibilité des expressions régulières, le gain ne serait pas significatif. "
"Une autre utilisation consiste à spécifier des portions d'une RE qui peuvent "
"être répétées un certain nombre de fois."
#: ../Doc/howto/regex.rst:170
msgid ""
"The first metacharacter for repeating things that we'll look at is ``*``. "
"``*`` doesn't match the literal character ``'*'``; instead, it specifies "
"that the previous character can be matched zero or more times, instead of "
"exactly once."
msgstr ""
"Le premier métacaractère pour la répétition que nous abordons est ``*``. "
"``*`` ne correspond pas au caractère littéral ``'*'`` ; à la place, il "
"spécifie que le caractère précédent peut correspondre zéro, une ou plusieurs "
"fois (au lieu d'une seule fois)."
#: ../Doc/howto/regex.rst:174
msgid ""
"For example, ``ca*t`` will match ``'ct'`` (0 ``'a'`` characters), ``'cat'`` "
"(1 ``'a'``), ``'caaat'`` (3 ``'a'`` characters), and so forth."
msgstr ""
"Par exemple, ``cha*t`` correspond à ``'cht'`` (0 caractère ``'a'``), "
"``'chat'`` (1 ``'a'``), ``'chaaat'`` (3 caractères ``'a'``) et ainsi de "
"suite."
#: ../Doc/howto/regex.rst:177
msgid ""
"Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the "
"matching engine will try to repeat it as many times as possible. If later "
"portions of the pattern don't match, the matching engine will then back up "
"and try again with fewer repetitions."
msgstr ""
"Les répétitions telles que ``*`` sont :dfn:`gloutonnes` ; quand vous répétez "
"une RE, le moteur de correspondance essaie de trouver la correspondance la "
"plus longue en répétant le motif tant qu'il le peut. Si la suite du motif ne "
"correspond pas, le moteur de correspondance revient en arrière et essaie "
"avec moins de répétitions."
#: ../Doc/howto/regex.rst:182
msgid ""
"A step-by-step example will make this more obvious. Let's consider the "
"expression ``a[bcd]*b``. This matches the letter ``'a'``, zero or more "
"letters from the class ``[bcd]``, and finally ends with a ``'b'``. Now "
"imagine matching this RE against the string ``'abcbd'``."
msgstr ""
"Un exemple étape par étape mettra les choses au clair. Considérons "
"l'expression ``a[bcd]*b``. Elle correspond à la lettre ``'a'``, suivi "
"d'aucune ou plusieurs lettres de la classe `[bcd]`` et finit par un ``'b'``. "
"Maintenant, supposons que nous cherchons une correspondance de cette RE avec "
"la chaîne de caractères ``'abcbd'``."
#: ../Doc/howto/regex.rst:188
msgid "Step"
msgstr "Étape"
#: ../Doc/howto/regex.rst:188
msgid "Matched"
msgstr "Correspond"
#: ../Doc/howto/regex.rst:188
msgid "Explanation"
msgstr "Explication"
#: ../Doc/howto/regex.rst:190
msgid "1"
msgstr "1"
#: ../Doc/howto/regex.rst:190
msgid "``a``"
msgstr "``a``"
#: ../Doc/howto/regex.rst:190
msgid "The ``a`` in the RE matches."
msgstr "Le ``a`` correspond dans la RE."
#: ../Doc/howto/regex.rst:192
msgid "2"
msgstr "2"
#: ../Doc/howto/regex.rst:192
msgid "``abcbd``"
msgstr "``abcbd``"
#: ../Doc/howto/regex.rst:192
msgid ""
"The engine matches ``[bcd]*``, going as far as it can, which is to the end "
"of the string."
msgstr ""
"Le moteur de correspondance trouve ``[bcd]*``, va aussi loin qu'il le peut, "
"ce qui n'est pas la fin de la chaîne."
#: ../Doc/howto/regex.rst:196
msgid "3"
msgstr "3"
#: ../Doc/howto/regex.rst:196 ../Doc/howto/regex.rst:204
msgid "*Failure*"
msgstr "*échec*"
#: ../Doc/howto/regex.rst:196
msgid ""
"The engine tries to match ``b``, but the current position is at the end of "
"the string, so it fails."
msgstr ""
"Le moteur essaie de trouver une correspondance avec ``b`` mais la position "
"courante est à la fin de la chaîne de caractères, donc il échoue."
#: ../Doc/howto/regex.rst:201
msgid "4"
msgstr "4"
#: ../Doc/howto/regex.rst:201 ../Doc/howto/regex.rst:212
msgid "``abcb``"
msgstr "``abcb``"
#: ../Doc/howto/regex.rst:201
msgid "Back up, so that ``[bcd]*`` matches one less character."
msgstr ""
"Retour en arrière, de manière à ce que ``[bcd]*`` corresponde avec un "
"caractère de moins."
#: ../Doc/howto/regex.rst:204
msgid "5"
msgstr "5"
#: ../Doc/howto/regex.rst:204
msgid ""
"Try ``b`` again, but the current position is at the last character, which is "
"a ``'d'``."
msgstr ""
"Essaie encore ``b``, mais la position courante est le dernier caractère, qui "
"est ``'d'``."
#: ../Doc/howto/regex.rst:208 ../Doc/howto/regex.rst:212
msgid "6"
msgstr "6"
#: ../Doc/howto/regex.rst:208
msgid "``abc``"
msgstr "``abc``"
#: ../Doc/howto/regex.rst:208
msgid "Back up again, so that ``[bcd]*`` is only matching ``bc``."
msgstr ""
"Encore un retour en arrière, de manière à ce que ``[bcd]*`` ne corresponde "
"qu'à ``bc``."
#: ../Doc/howto/regex.rst:212
msgid ""
"Try ``b`` again. This time the character at the current position is "
"``'b'``, so it succeeds."
msgstr ""
"Essaie ``b`` encore une fois. Cette fois, le caractère à la position "
"courante est ``'b'``, donc cela fonctionne."
#: ../Doc/howto/regex.rst:218
msgid ""
"The end of the RE has now been reached, and it has matched ``'abcb'``. This "
"demonstrates how the matching engine goes as far as it can at first, and if "
"no match is found it will then progressively back up and retry the rest of "
"the RE again and again. It will back up until it has tried zero matches for "
"``[bcd]*``, and if that subsequently fails, the engine will conclude that "
"the string doesn't match the RE at all."
msgstr ""
"La fin de la RE est maintenant atteinte et la correspondance trouvée est "
"``'abcb'``. Ceci démontre comment le moteur de correspondance essaie d'aller "
"le plus loin possible en premier et, si la correspondance échoue, il revient "
"progressivement en arrière et ré-essaie avec le reste de la RE encore et "
"encore. Il revient en arrière jusqu'à qu'il n'y ait aucune correspondance "
"pour ``[bcd]*`` et, si cela échoue toujours, le moteur conclut que la chaîne "
"de caractères et la RE ne correspondent pas du tout."
#: ../Doc/howto/regex.rst:225
msgid ""
"Another repeating metacharacter is ``+``, which matches one or more times. "
"Pay careful attention to the difference between ``*`` and ``+``; ``*`` "
"matches *zero* or more times, so whatever's being repeated may not be "
"present at all, while ``+`` requires at least *one* occurrence. To use a "
"similar example, ``ca+t`` will match ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 "
"``'a'``\\ s), but won't match ``'ct'``."
msgstr ""
"Un autre métacaractère de répétition est ``+``, qui fait correspondre une ou "
"plusieurs fois. Faites bien attention à la différence entre ``*`` et ``+`` ; "
"``*`` fait correspondre *zero* fois ou plus, ainsi ce qui doit être répété "
"peut ne pas être présent du tout, alors que ``+`` requiert au moins *une* "
"occurrence. Pour continuer avec le même exemple, ``cha+t`` correspond avec "
"``'chat'`` (1 ``'a'``), ``'chaaat'`` (3 ``'a'``) mais ne correspond pas avec "
"``'ct'``."
#: ../Doc/howto/regex.rst:232
msgid ""
"There are two more repeating qualifiers. The question mark character, ``?"
"``, matches either once or zero times; you can think of it as marking "
"something as being optional. For example, ``home-?brew`` matches either "
"``'homebrew'`` or ``'home-brew'``."
msgstr ""
"Il existe deux autres quantificateurs pour les répétitions. Le point "
"d'interrogation, ``?``, fait correspondre zéro ou une fois ; vous pouvez "
"vous le représenter comme indiquant une option. Par exemple, ``méta-?"
"caractère`` fait correspondre soit ``métacaractère``, soit ``méta-"
"caractère``."
#: ../Doc/howto/regex.rst:237
msgid ""
"The most complicated repeated qualifier is ``{m,n}``, where *m* and *n* are "
"decimal integers. This qualifier means there must be at least *m* "
"repetitions, and at most *n*. For example, ``a/{1,3}b`` will match ``'a/"
"b'``, ``'a//b'``, and ``'a///b'``. It won't match ``'ab'``, which has no "
"slashes, or ``'a////b'``, which has four."
msgstr ""
"Le plus compliqué des quantificateurs est ``{m,n}`` où *m* et *n* sont des "
"entiers décimaux. Ce quantificateur indique qu'il faut au moins *m* "
"répétitions et au plus *n*. Par exemple, ``a/{1,3}b`` fait correspondre ``'a/"
"b'``, ``'a//b'`` et ``'a///b'``. Elle ne fait pas correspondre ``'ab'`` (pas "
"de barre oblique) ni ``'a////b'`` (quatre barres obliques)."
#: ../Doc/howto/regex.rst:243
msgid ""
"You can omit either *m* or *n*; in that case, a reasonable value is assumed "
"for the missing value. Omitting *m* is interpreted as a lower limit of 0, "
"while omitting *n* results in an upper bound of infinity."
msgstr ""
"Vous pouvez omettre soit *m*, soit *n* ; dans ce cas, une valeur raisonnable "
"est prise pour la valeur manquante. Omettre *m* considère que la borne basse "
"est 0 alors qu'omettre *n* signifie qu'il n'y a pas de borne supérieure."
#: ../Doc/howto/regex.rst:247
msgid ""
"Readers of a reductionist bent may notice that the three other qualifiers "
"can all be expressed using this notation. ``{0,}`` is the same as ``*``, "
"``{1,}`` is equivalent to ``+``, and ``{0,1}`` is the same as ``?``. It's "
"better to use ``*``, ``+``, or ``?`` when you can, simply because they're "
"shorter and easier to read."
msgstr ""
"Le lecteur attentif aura noté que les trois premiers quantificateurs peuvent "
"être exprimés en utilisant cette notation. ``{0,}`` est la même chose que "
"``*``, ``{1,}`` est équivalent à ``+`` et ``{0,1}`` se comporte comme ``?``. "
"Il est préférable d'utiliser ``*``, ``+`` ou ``?`` quand vous le pouvez, "
"simplement parce qu'ils sont plus courts et plus faciles à lire."
#: ../Doc/howto/regex.rst:255
msgid "Using Regular Expressions"
msgstr "Utilisation des expressions régulières"
#: ../Doc/howto/regex.rst:257
msgid ""
"Now that we've looked at some simple regular expressions, how do we actually "
"use them in Python? The :mod:`re` module provides an interface to the "
"regular expression engine, allowing you to compile REs into objects and then "
"perform matches with them."
msgstr ""
"Maintenant que nous avons vu quelques expressions régulières simples, "
"utilisons-les concrètement. Le module :mod:`re` fournit une interface pour "
"le moteur de correspondance, ce qui permet de compiler les RE en objets et "
"d'effectuer des correspondances avec."
#: ../Doc/howto/regex.rst:264
msgid "Compiling Regular Expressions"
msgstr "Compilation des expressions régulières"
#: ../Doc/howto/regex.rst:266
msgid ""
"Regular expressions are compiled into pattern objects, which have methods "
"for various operations such as searching for pattern matches or performing "
"string substitutions. ::"
msgstr ""
"Les expressions régulières sont compilées en objets motifs, qui possèdent "
"des méthodes pour diverses opérations telles que la recherche de "
"correspondances ou le remplacement dans les chaînes. ::"
#: ../Doc/howto/regex.rst:275
msgid ""
":func:`re.compile` also accepts an optional *flags* argument, used to enable "
"various special features and syntax variations. We'll go over the available "
"settings later, but for now a single example will do::"
msgstr ""
":func:`re.compile` accepte aussi une option *flags*, utilisée pour activer "
"des fonctionnalités particulières et des variations de syntaxe. Nous "
"étudierons la définition des variables plus tard et, pour l'instant, un seul "
"exemple suffit ::"
#: ../Doc/howto/regex.rst:281
msgid ""
"The RE is passed to :func:`re.compile` as a string. REs are handled as "
"strings because regular expressions aren't part of the core Python language, "
"and no special syntax was created for expressing them. (There are "
"applications that don't need REs at all, so there's no need to bloat the "
"language specification by including them.) Instead, the :mod:`re` module is "
"simply a C extension module included with Python, just like the :mod:"
"`socket` or :mod:`zlib` modules."
msgstr ""
"La RE passée à :func:`re.compile` est une chaîne. Les RE sont des chaînes "
"car les expressions régulières ne font pas partie intrinsèque du langage "
"Python et aucune syntaxe particulière n'a été créée pour les exprimer (il "
"existe des applications qui ne nécessitent aucune RE et il n'a donc aucune "
"raison de grossir les spécifications du langage en incluant les RE). Ainsi, "
"le module :mod:`re` est simplement un module d'extension en C inclus dans "
"Python, tout comme les modules :mod:`socket` ou :mod:`zlib`."
#: ../Doc/howto/regex.rst:288
msgid ""
"Putting REs in strings keeps the Python language simpler, but has one "
"disadvantage which is the topic of the next section."
msgstr ""
"Exprimer les RE comme des chaînes de caractères garde le langage Python plus "
"simple mais introduit un inconvénient qui fait l'objet de la section "
"suivante."
#: ../Doc/howto/regex.rst:295
msgid "The Backslash Plague"
msgstr "La maudite barre oblique inverse"
#: ../Doc/howto/regex.rst:297
msgid ""
"As stated earlier, regular expressions use the backslash character "
"(``'\\'``) to indicate special forms or to allow special characters to be "
"used without invoking their special meaning. This conflicts with Python's "
"usage of the same character for the same purpose in string literals."
msgstr ""
"Comme indiqué précédemment, les expressions régulières utilisent la barre "
"oblique inverse (*backslash* en anglais) pour indiquer des constructions "
"particulières ou pour autoriser des caractères spéciaux sans que leur "
"signification spéciale ne soit invoquée. C'est en contradiction avec l'usage "
"de Python qui est qu'un caractère doit avoir la même signification dans les "
"littéraux de chaînes de caractères."
#: ../Doc/howto/regex.rst:302
msgid ""
"Let's say you want to write a RE that matches the string ``\\section``, "
"which might be found in a LaTeX file. To figure out what to write in the "
"program code, start with the desired string to be matched. Next, you must "
"escape any backslashes and other metacharacters by preceding them with a "
"backslash, resulting in the string ``\\\\section``. The resulting string "
"that must be passed to :func:`re.compile` must be ``\\\\section``. However, "
"to express this as a Python string literal, both backslashes must be escaped "
"*again*."
msgstr ""
"Considérons que vous voulez écrire une RE qui fait correspondre la chaîne de "
"caractères ``\\section`` (on en trouve dans un fichier LaTeX). Pour savoir "
"ce qu'il faut coder dans votre programme, commençons par la chaîne de "
"caractères cherchée. Ensuite, nous devons échapper chaque barre oblique "
"inverse et tout autre métacaractère en les précédant d'une barre oblique "
"inverse, ce qui donne la chaîne de caractères ``\\\\section``. La chaîne "
"résultante qui doit être passée à :func:`re.compile` est donc ``\\"
"\\section``. Comme nous devons l'exprimer sous la forme d'une chaîne "
"littérale Python, nous devons échapper les deux barres obliques inverses "
"*encore une fois*."
#: ../Doc/howto/regex.rst:311
msgid "Characters"
msgstr "Caractères"
#: ../Doc/howto/regex.rst:311
msgid "Stage"
msgstr "Niveau"
#: ../Doc/howto/regex.rst:313
msgid "``\\section``"
msgstr "``\\section``"
#: ../Doc/howto/regex.rst:313
msgid "Text string to be matched"
msgstr "Chaîne de caractère à chercher"
#: ../Doc/howto/regex.rst:315
msgid "``\\\\section``"
msgstr "``\\\\section``"
#: ../Doc/howto/regex.rst:315
msgid "Escaped backslash for :func:`re.compile`"
msgstr "Barre oblique inverse échappée pour :func:`re.compile`"
#: ../Doc/howto/regex.rst:317 ../Doc/howto/regex.rst:344
msgid "``\"\\\\\\\\section\"``"
msgstr "``\"\\\\\\\\section\"``"
#: ../Doc/howto/regex.rst:317
msgid "Escaped backslashes for a string literal"
msgstr ""
"Barres obliques inverses échappées pour un littéral de chaîne de caractères"
#: ../Doc/howto/regex.rst:320
msgid ""
"In short, to match a literal backslash, one has to write ``'\\\\\\\\'`` as "
"the RE string, because the regular expression must be ``\\\\``, and each "
"backslash must be expressed as ``\\\\`` inside a regular Python string "
"literal. In REs that feature backslashes repeatedly, this leads to lots of "
"repeated backslashes and makes the resulting strings difficult to understand."
msgstr ""
"Pour faire court, si vous cherchez une correspondance pour une barre oblique "
"inverse littérale, écrivez ``'\\\\\\\\'`` dans votre chaîne RE, car "
"l'expression régulière doit être ``\\\\`` et que chaque barre oblique "
"inverse doit être exprimée comme ``\\\\`` dans un littéral chaîne de "
"caractères Python. Dans les RE qui comportent plusieurs barres obliques "
"inverses, cela conduit à beaucoup de barres obliques inverses et rend la "
"chaîne résultante difficile à comprendre."
#: ../Doc/howto/regex.rst:326
msgid ""
"The solution is to use Python's raw string notation for regular expressions; "
"backslashes are not handled in any special way in a string literal prefixed "
"with ``'r'``, so ``r\"\\n\"`` is a two-character string containing ``'\\'`` "
"and ``'n'``, while ``\"\\n\"`` is a one-character string containing a "
"newline. Regular expressions will often be written in Python code using this "
"raw string notation."
msgstr ""
"La solution consiste à utiliser les chaînes brutes Python pour les "
"expressions régulières ; les barres obliques inverses ne sont pas gérées "
"d'une manière particulière dans les chaînes littérales préfixées avec "
"``'r'``. Ainsi, ``r\"\\n\"`` est la chaîne de deux caractères contenant "
"``'\\'`` et ``'n'`` alors que ``\"\\n\"`` est la chaîne contenant uniquement "
"le caractère retour à la ligne. Les expressions régulières sont souvent "
"écrites dans le code Python en utilisant la notation \"chaînes brutes\"."
#: ../Doc/howto/regex.rst:332
msgid ""
"In addition, special escape sequences that are valid in regular expressions, "
"but not valid as Python string literals, now result in a :exc:"
"`DeprecationWarning` and will eventually become a :exc:`SyntaxError`, which "
"means the sequences will be invalid if raw string notation or escaping the "
"backslashes isn't used."
msgstr ""
"En complément, les séquences d'échappement valides dans les expressions "
"régulières, mais non valides dans les littéraux chaînes classiques, "
"produisent dorénavant un :exc:`DeprecationWarning` et, possiblement, "
"deviendront une :exc:`SyntaxError`, ce qui signifie que les séquences seront "
"invalides si la notation \"chaîne brute\" ou l'échappement des barres "
"obliques inverses ne sont pas utilisés."
#: ../Doc/howto/regex.rst:340
msgid "Regular String"
msgstr "Chaîne normale"
#: ../Doc/howto/regex.rst:340
msgid "Raw string"
msgstr "Chaîne de caractères brute"
#: ../Doc/howto/regex.rst:342
msgid "``\"ab*\"``"
msgstr "``\"ab*\"``"
#: ../Doc/howto/regex.rst:342
msgid "``r\"ab*\"``"
msgstr "``r\"ab*\"``"
#: ../Doc/howto/regex.rst:344
msgid "``r\"\\\\section\"``"
msgstr "``r\"\\\\section\"``"
#: ../Doc/howto/regex.rst:346
msgid "``\"\\\\w+\\\\s+\\\\1\"``"
msgstr "``\"\\\\w+\\\\s+\\\\1\"``"
#: ../Doc/howto/regex.rst:346
msgid "``r\"\\w+\\s+\\1\"``"
msgstr "``r\"\\w+\\s+\\1\"``"
#: ../Doc/howto/regex.rst:351
msgid "Performing Matches"
msgstr "Recherche de correspondances"
#: ../Doc/howto/regex.rst:353
msgid ""
"Once you have an object representing a compiled regular expression, what do "
"you do with it? Pattern objects have several methods and attributes. Only "
"the most significant ones will be covered here; consult the :mod:`re` docs "
"for a complete listing."
msgstr ""
"Une fois que nous avons un objet représentant une expression régulière "
"compilée, qu'en faisons-nous ? Les objets motifs ont plusieurs méthodes et "
"attributs. Seuls les plus significatifs seront couverts ici ; consultez la "
"documentation :mod:`re` pour la liste complète."
#: ../Doc/howto/regex.rst:359 ../Doc/howto/regex.rst:417
#: ../Doc/howto/regex.rst:1056
msgid "Method/Attribute"
msgstr "Méthode/Attribut"
#: ../Doc/howto/regex.rst:359 ../Doc/howto/regex.rst:417
#: ../Doc/howto/regex.rst:1056
msgid "Purpose"
msgstr "Objectif"
#: ../Doc/howto/regex.rst:361
msgid "``match()``"
msgstr "``match()``"
#: ../Doc/howto/regex.rst:361
msgid "Determine if the RE matches at the beginning of the string."
msgstr "Détermine si la RE fait correspond dès le début de la chaîne."
#: ../Doc/howto/regex.rst:364
msgid "``search()``"
msgstr "``search()``"
#: ../Doc/howto/regex.rst:364
msgid "Scan through a string, looking for any location where this RE matches."
msgstr "Analyse la chaîne à la recherche d'une position où la RE correspond."
#: ../Doc/howto/regex.rst:367
msgid "``findall()``"
msgstr "``findall()``"
#: ../Doc/howto/regex.rst:367
msgid "Find all substrings where the RE matches, and returns them as a list."
msgstr ""
"Trouve toutes les sous-chaînes qui correspondent à la RE et les renvoie sous "
"la forme d'une liste."
#: ../Doc/howto/regex.rst:370
msgid "``finditer()``"
msgstr "``finditer()``"
#: ../Doc/howto/regex.rst:370
msgid ""
"Find all substrings where the RE matches, and returns them as an :term:"
"`iterator`."
msgstr ""
"Trouve toutes les sous-chaînes qui correspondent à la RE et les renvoie sous "
"la forme d'un :term:`itérateur <iterator>`."
#: ../Doc/howto/regex.rst:374
msgid ""
":meth:`~re.Pattern.match` and :meth:`~re.Pattern.search` return ``None`` if "
"no match can be found. If they're successful, a :ref:`match object <match-"
"objects>` instance is returned, containing information about the match: "
"where it starts and ends, the substring it matched, and more."
msgstr ""
":meth:`~re.Pattern.match` et :meth:`~re.Pattern.search` renvoient ``None`` "
"si aucune correspondance ne peut être trouvée. Si elles trouvent une "
"correspondance, une instance d'objet :ref:`correspondance <match-objects>` "
"est renvoyée, contenant les informations relatives à la correspondance : "
"position de départ et de fin, la sous-chaîne qui correspond et d'autres "
"informations."
#: ../Doc/howto/regex.rst:379
msgid ""
"You can learn about this by interactively experimenting with the :mod:`re` "
"module. If you have :mod:`tkinter` available, you may also want to look at :"
"source:`Tools/demo/redemo.py`, a demonstration program included with the "
"Python distribution. It allows you to enter REs and strings, and displays "
"whether the RE matches or fails. :file:`redemo.py` can be quite useful when "
"trying to debug a complicated RE."
msgstr ""
"Vous pouvez apprendre leur fonctionnement en expérimentant de manière "
"interactive avec le module :mod:`re`. Si vous disposez de :mod:`tkinter`, "
"vous pouvez aussi regarder les sources de :source:`Tools/demo/redemo.py`, un "
"programme de démonstration inclus dans la distribution Python. Ce programme "
"vous permet de rentrer des RE et des chaînes, affichant si la RE correspond "
"ou pas. :file:`redemo.py` peut s'avérer particulièrement utile quand vous "
"devez déboguer une RE compliquée."
#: ../Doc/howto/regex.rst:386
msgid ""
"This HOWTO uses the standard Python interpreter for its examples. First, run "
"the Python interpreter, import the :mod:`re` module, and compile a RE::"
msgstr ""
"Ce guide utilise l'interpréteur standard de Python pour ses exemples. "
"Commencez par lancer l'interpréteur Python, importez le module :mod:`re` et "
"compilez une RE ::"
#: ../Doc/howto/regex.rst:394
msgid ""
"Now, you can try matching various strings against the RE ``[a-z]+``. An "
"empty string shouldn't match at all, since ``+`` means 'one or more "
"repetitions'. :meth:`~re.Pattern.match` should return ``None`` in this case, "
"which will cause the interpreter to print no output. You can explicitly "
"print the result of :meth:`!match` to make this clear. ::"
msgstr ""
"Maintenant, vous pouvez tester des correspondances de la RE ``[a-z]+`` avec "
"différentes chaînes. Une chaîne vide ne doit pas correspondre, puisque ``+`` "
"indique \"une ou plusieurs occurrences\". :meth:`~re.Pattern.match` doit "
"renvoyer ``None`` dans ce cas, ce qui fait que l'interpréteur n'affiche "
"rien. Vous pouvez afficher le résultat de :meth:`!match` explicitement pour "
"que ce soit clair. ::"
#: ../Doc/howto/regex.rst:404
msgid ""
"Now, let's try it on a string that it should match, such as ``tempo``. In "
"this case, :meth:`~re.Pattern.match` will return a :ref:`match object <match-"
"objects>`, so you should store the result in a variable for later use. ::"
msgstr ""
"Maintenant, essayons sur une chaîne qui doit correspondre, par exemple "
"``tempo``. Dans ce cas, :meth:`~re.Pattern.match` renvoie un :ref:`objet "
"correspondance <match-objects>`, vous pouvez ainsi stocker le résultat dans "
"une variable pour une utilisation ultérieure. ::"
#: ../Doc/howto/regex.rst:412
msgid ""
"Now you can query the :ref:`match object <match-objects>` for information "
"about the matching string. Match object instances also have several methods "
"and attributes; the most important ones are:"
msgstr ""
"Maintenant, vous pouvez interroger :ref:`l'objet correspondance <match-"
"objects>` pour obtenir des informations sur la chaîne qui correspond. Les "
"instances d'objets correspondances possèdent plusieurs méthodes et "
"attributs ; les plus importantes sont :"
#: ../Doc/howto/regex.rst:419
msgid "``group()``"
msgstr "``group()``"
#: ../Doc/howto/regex.rst:419
msgid "Return the string matched by the RE"
msgstr "Retourne la chaîne de caractères correspondant à la RE"
#: ../Doc/howto/regex.rst:421
msgid "``start()``"
msgstr "``start()``"
#: ../Doc/howto/regex.rst:421
msgid "Return the starting position of the match"
msgstr "Retourne la position de début de la correspondance"
#: ../Doc/howto/regex.rst:423
msgid "``end()``"
msgstr "``end()``"
#: ../Doc/howto/regex.rst:423
msgid "Return the ending position of the match"
msgstr "Retourne la position de fin de la correspondance"
#: ../Doc/howto/regex.rst:425
msgid "``span()``"
msgstr "``span()``"
#: ../Doc/howto/regex.rst:425
msgid "Return a tuple containing the (start, end) positions of the match"
msgstr ""
"Renvoie un *tuple* contenant les positions (début, fin) de la correspondance."
#: ../Doc/howto/regex.rst:429
msgid "Trying these methods will soon clarify their meaning::"
msgstr "Essayons ces méthodes pour clarifier leur signification ::"
#: ../Doc/howto/regex.rst:438
msgid ""
":meth:`~re.Match.group` returns the substring that was matched by the RE. :"
"meth:`~re.Match.start` and :meth:`~re.Match.end` return the starting and "
"ending index of the match. :meth:`~re.Match.span` returns both start and end "
"indexes in a single tuple. Since the :meth:`~re.Pattern.match` method only "
"checks if the RE matches at the start of a string, :meth:`!start` will "
"always be zero. However, the :meth:`~re.Pattern.search` method of patterns "
"scans through the string, so the match may not start at zero in that "
"case. ::"
msgstr ""
":meth:`~re.Match.group` renvoie la sous-chaîne qui correspond à la RE. :meth:"
"`~re.Match.start` et :meth:`~re.Match.end` renvoient les indices de début et "
"de fin de la correspondance. :meth:`~re.Match.span` renvoie les indices de "
"début et de fin dans un simple *tuple*. Comme la méthode :meth:`~re.Pattern."
"match` ne fait que vérifier si la RE correspond au début de la chaîne, :meth:"
"`!start` vaut toujours zéro. Cependant, la méthode :meth:`~re.Pattern."
"search` d'un motif analyse toute la chaîne, afin de trouver une "
"correspondance potentielle qui ne commence pas à zéro. ::"
#: ../Doc/howto/regex.rst:455
msgid ""
"In actual programs, the most common style is to store the :ref:`match object "
"<match-objects>` in a variable, and then check if it was ``None``. This "
"usually looks like::"
msgstr ""
"Dans les programmes réels, le style le plus classique consiste à stocker :"
"ref:`l'objet correspondance <match-objects>` dans une variable, puis à "
"vérifier s'il vaut ``None``. Généralement, cela ressemble à ceci ::"
#: ../Doc/howto/regex.rst:466
msgid ""
"Two pattern methods return all of the matches for a pattern. :meth:`~re."
"Pattern.findall` returns a list of matching strings::"
msgstr ""
"Deux méthodes de motifs renvoient toutes les correspondances pour un motif. :"
"meth:`~re.Pattern.findall` renvoie une liste des chaînes qui correspondent ::"
#: ../Doc/howto/regex.rst:473
msgid ""
"The ``r`` prefix, making the literal a raw string literal, is needed in this "
"example because escape sequences in a normal \"cooked\" string literal that "
"are not recognized by Python, as opposed to regular expressions, now result "
"in a :exc:`DeprecationWarning` and will eventually become a :exc:"
"`SyntaxError`. See :ref:`the-backslash-plague`."
msgstr ""
"Le préfixe ``r`` , qui indique une chaîne brute littérale, est nécessaire "
"dans cet exemple car les séquences d'échappement dans une chaîne littérale "
"qui ne sont pas reconnues par Python, alors qu'elles le sont par les "
"expressions régulières, induisent maintenant un :exc:`DeprecationWarning` et "
"deviendront possiblement des :exc:`SyntaxError`. Reportez-vous à :ref:`the-"
"backslash-plague`."
#: ../Doc/howto/regex.rst:479
msgid ""
":meth:`~re.Pattern.findall` has to create the entire list before it can be "
"returned as the result. The :meth:`~re.Pattern.finditer` method returns a "
"sequence of :ref:`match object <match-objects>` instances as an :term:"
"`iterator`::"
msgstr ""
":meth:`~re.Pattern.findall` doit créer la liste entière avant d'être renvoyé "
"comme résultat. La méthode :meth:`~re.Pattern.finditer` renvoie une séquence "
"d'instances :ref:`d'objets correspondances <match-objects>` en tant qu'\\ :"
"term:`itérateur <iterator>` ::"
#: ../Doc/howto/regex.rst:495
msgid "Module-Level Functions"
msgstr ""
#: ../Doc/howto/regex.rst:497
msgid ""
"You don't have to create a pattern object and call its methods; the :mod:"
"`re` module also provides top-level functions called :func:`~re.match`, :"
"func:`~re.search`, :func:`~re.findall`, :func:`~re.sub`, and so forth. "
"These functions take the same arguments as the corresponding pattern method "
"with the RE string added as the first argument, and still return either "
"``None`` or a :ref:`match object <match-objects>` instance. ::"
msgstr ""
#: ../Doc/howto/regex.rst:509
msgid ""
"Under the hood, these functions simply create a pattern object for you and "
"call the appropriate method on it. They also store the compiled object in a "
"cache, so future calls using the same RE won't need to parse the pattern "
"again and again."
msgstr ""
#: ../Doc/howto/regex.rst:514
msgid ""
"Should you use these module-level functions, or should you get the pattern "
"and call its methods yourself? If you're accessing a regex within a loop, "
"pre-compiling it will save a few function calls. Outside of loops, there's "
"not much difference thanks to the internal cache."
msgstr ""
#: ../Doc/howto/regex.rst:522
msgid "Compilation Flags"
msgstr "Fanion de Compilation"
#: ../Doc/howto/regex.rst:524
msgid ""
"Compilation flags let you modify some aspects of how regular expressions "
"work. Flags are available in the :mod:`re` module under two names, a long "
"name such as :const:`IGNORECASE` and a short, one-letter form such as :const:"
"`I`. (If you're familiar with Perl's pattern modifiers, the one-letter "
"forms use the same letters; the short form of :const:`re.VERBOSE` is :const:"
"`re.X`, for example.) Multiple flags can be specified by bitwise OR-ing "
"them; ``re.I | re.M`` sets both the :const:`I` and :const:`M` flags, for "
"example."
msgstr ""
#: ../Doc/howto/regex.rst:532
msgid ""
"Here's a table of the available flags, followed by a more detailed "
"explanation of each one."
msgstr ""
#: ../Doc/howto/regex.rst:536
msgid "Flag"
msgstr "Option"
#: ../Doc/howto/regex.rst:536
msgid "Meaning"
msgstr "Signification"
#: ../Doc/howto/regex.rst:538
msgid ":const:`ASCII`, :const:`A`"
msgstr ""
#: ../Doc/howto/regex.rst:538
msgid ""
"Makes several escapes like ``\\w``, ``\\b``, ``\\s`` and ``\\d`` match only "
"on ASCII characters with the respective property."
msgstr ""
#: ../Doc/howto/regex.rst:542
msgid ":const:`DOTALL`, :const:`S`"
msgstr ""
#: ../Doc/howto/regex.rst:542
msgid "Make ``.`` match any character, including newlines."
msgstr ""
"Fait en sorte que ``.`` corresponde à n'importe quel caractère, caractère de "
"retour à la ligne inclus."
#: ../Doc/howto/regex.rst:545
msgid ":const:`IGNORECASE`, :const:`I`"
msgstr ""
#: ../Doc/howto/regex.rst:545
msgid "Do case-insensitive matches."
msgstr "Rechercher une correspondance non-sensible à la casse."
#: ../Doc/howto/regex.rst:547
msgid ":const:`LOCALE`, :const:`L`"
msgstr ""
#: ../Doc/howto/regex.rst:547
msgid "Do a locale-aware match."
msgstr "Rechercher une correspondance sensible à la langue locale."
#: ../Doc/howto/regex.rst:549
msgid ":const:`MULTILINE`, :const:`M`"
msgstr ""
#: ../Doc/howto/regex.rst:549
msgid "Multi-line matching, affecting ``^`` and ``$``."
msgstr "Correspondance multi-ligne, affectant ``^`` et ``$``."
#: ../Doc/howto/regex.rst:552
msgid ":const:`VERBOSE`, :const:`X` (for 'extended')"
msgstr ""
#: ../Doc/howto/regex.rst:552
msgid ""
"Enable verbose REs, which can be organized more cleanly and understandably."
msgstr ""
"Activer les RE verbeuses, qui peuvent être organisées de manière plus propre "
"et compréhensible."
#: ../Doc/howto/regex.rst:561
msgid ""
"Perform case-insensitive matching; character class and literal strings will "
"match letters by ignoring case. For example, ``[A-Z]`` will match lowercase "
"letters, too. Full Unicode matching also works unless the :const:`ASCII` "
"flag is used to disable non-ASCII matches. When the Unicode patterns ``[a-"
"z]`` or ``[A-Z]`` are used in combination with the :const:`IGNORECASE` flag, "
"they will match the 52 ASCII letters and 4 additional non-ASCII letters: "
"'İ' (U+0130, Latin capital letter I with dot above), 'ı' (U+0131, Latin "
"small letter dotless i), 'ſ' (U+017F, Latin small letter long s) and '' (U"
"+212A, Kelvin sign). ``Spam`` will match ``'Spam'``, ``'spam'``, "
"``'spAM'``, or ``'ſpam'`` (the latter is matched only in Unicode mode). This "
"lowercasing doesn't take the current locale into account; it will if you "
"also set the :const:`LOCALE` flag."
msgstr ""
#: ../Doc/howto/regex.rst:579
msgid ""
"Make ``\\w``, ``\\W``, ``\\b``, ``\\B`` and case-insensitive matching "
"dependent on the current locale instead of the Unicode database."
msgstr ""
#: ../Doc/howto/regex.rst:582
msgid ""
"Locales are a feature of the C library intended to help in writing programs "
"that take account of language differences. For example, if you're "
"processing encoded French text, you'd want to be able to write ``\\w+`` to "
"match words, but ``\\w`` only matches the character class ``[A-Za-z]`` in "
"bytes patterns; it won't match bytes corresponding to ``é`` or ``ç``. If "
"your system is configured properly and a French locale is selected, certain "
"C functions will tell the program that the byte corresponding to ``é`` "
"should also be considered a letter. Setting the :const:`LOCALE` flag when "
"compiling a regular expression will cause the resulting compiled object to "
"use these C functions for ``\\w``; this is slower, but also enables ``\\w+`` "
"to match French words as you'd expect. The use of this flag is discouraged "
"in Python 3 as the locale mechanism is very unreliable, it only handles one "
"\"culture\" at a time, and it only works with 8-bit locales. Unicode "
"matching is already enabled by default in Python 3 for Unicode (str) "
"patterns, and it is able to handle different locales/languages."
msgstr ""
#: ../Doc/howto/regex.rst:604
msgid ""
"(``^`` and ``$`` haven't been explained yet; they'll be introduced in "
"section :ref:`more-metacharacters`.)"
msgstr ""
"(``^`` et ``$`` n'ont pas encore été expliqués; ils seront introduit dans le "
"section :ref:`more-metacharacters`.)"
#: ../Doc/howto/regex.rst:607
msgid ""
"Usually ``^`` matches only at the beginning of the string, and ``$`` matches "
"only at the end of the string and immediately before the newline (if any) at "
"the end of the string. When this flag is specified, ``^`` matches at the "
"beginning of the string and at the beginning of each line within the string, "
"immediately following each newline. Similarly, the ``$`` metacharacter "
"matches either at the end of the string and at the end of each line "
"(immediately preceding each newline)."
msgstr ""
#: ../Doc/howto/regex.rst:620
msgid ""
"Makes the ``'.'`` special character match any character at all, including a "
"newline; without this flag, ``'.'`` will match anything *except* a newline."
msgstr ""
#: ../Doc/howto/regex.rst:628
msgid ""
"Make ``\\w``, ``\\W``, ``\\b``, ``\\B``, ``\\s`` and ``\\S`` perform ASCII-"
"only matching instead of full Unicode matching. This is only meaningful for "
"Unicode patterns, and is ignored for byte patterns."
msgstr ""
#: ../Doc/howto/regex.rst:637
msgid ""
"This flag allows you to write regular expressions that are more readable by "
"granting you more flexibility in how you can format them. When this flag "
"has been specified, whitespace within the RE string is ignored, except when "
"the whitespace is in a character class or preceded by an unescaped "
"backslash; this lets you organize and indent the RE more clearly. This flag "
"also lets you put comments within a RE that will be ignored by the engine; "
"comments are marked by a ``'#'`` that's neither in a character class or "
"preceded by an unescaped backslash."
msgstr ""
#: ../Doc/howto/regex.rst:646
msgid ""
"For example, here's a RE that uses :const:`re.VERBOSE`; see how much easier "
"it is to read? ::"
msgstr ""
#: ../Doc/howto/regex.rst:659
msgid "Without the verbose setting, the RE would look like this::"
msgstr ""
#: ../Doc/howto/regex.rst:665
msgid ""
"In the above example, Python's automatic concatenation of string literals "
"has been used to break up the RE into smaller pieces, but it's still more "
"difficult to understand than the version using :const:`re.VERBOSE`."
msgstr ""
#: ../Doc/howto/regex.rst:671
msgid "More Pattern Power"
msgstr ""
#: ../Doc/howto/regex.rst:673
msgid ""
"So far we've only covered a part of the features of regular expressions. In "
"this section, we'll cover some new metacharacters, and how to use groups to "
"retrieve portions of the text that was matched."
msgstr ""
"Jusqu'à présent nous avons seulement couvert une partie des fonctionnalités "
"des expressions régulières. Dans cette section, nous couvrirons quelques "
"nouveaux métacaractères et comment utiliser les groupes pour récupérer des "
"portions de textes correspondante."
#: ../Doc/howto/regex.rst:681
msgid "More Metacharacters"
msgstr "Plus de métacaratères"
#: ../Doc/howto/regex.rst:683
msgid ""
"There are some metacharacters that we haven't covered yet. Most of them "
"will be covered in this section."
msgstr ""
#: ../Doc/howto/regex.rst:686
msgid ""
"Some of the remaining metacharacters to be discussed are :dfn:`zero-width "
"assertions`. They don't cause the engine to advance through the string; "
"instead, they consume no characters at all, and simply succeed or fail. For "
"example, ``\\b`` is an assertion that the current position is located at a "
"word boundary; the position isn't changed by the ``\\b`` at all. This means "
"that zero-width assertions should never be repeated, because if they match "
"once at a given location, they can obviously be matched an infinite number "
"of times."
msgstr ""
#: ../Doc/howto/regex.rst:702
msgid "``|``"
msgstr "``|``"
#: ../Doc/howto/regex.rst:695
msgid ""
"Alternation, or the \"or\" operator. If *A* and *B* are regular "
"expressions, ``A|B`` will match any string that matches either *A* or *B*. "
"``|`` has very low precedence in order to make it work reasonably when "
"you're alternating multi-character strings. ``Crow|Servo`` will match either "
"``'Crow'`` or ``'Servo'``, not ``'Cro'``, a ``'w'`` or an ``'S'``, and "
"``'ervo'``."
msgstr ""
#: ../Doc/howto/regex.rst:701
msgid ""
"To match a literal ``'|'``, use ``\\|``, or enclose it inside a character "
"class, as in ``[|]``."
msgstr ""
#: ../Doc/howto/regex.rst:717
msgid "``^``"
msgstr "``^``"
#: ../Doc/howto/regex.rst:705
msgid ""
"Matches at the beginning of lines. Unless the :const:`MULTILINE` flag has "
"been set, this will only match at the beginning of the string. In :const:"
"`MULTILINE` mode, this also matches immediately after each newline within "
"the string."
msgstr ""
#: ../Doc/howto/regex.rst:709
msgid ""
"For example, if you wish to match the word ``From`` only at the beginning of "
"a line, the RE to use is ``^From``. ::"
msgstr ""
#: ../Doc/howto/regex.rst:717
msgid "To match a literal ``'^'``, use ``\\^``."
msgstr ""
#: ../Doc/howto/regex.rst:731
msgid "``$``"
msgstr ""
#: ../Doc/howto/regex.rst:720
msgid ""
"Matches at the end of a line, which is defined as either the end of the "
"string, or any location followed by a newline character. ::"
msgstr ""
#: ../Doc/howto/regex.rst:730
msgid ""
"To match a literal ``'$'``, use ``\\$`` or enclose it inside a character "
"class, as in ``[$]``."
msgstr ""
#: ../Doc/howto/regex.rst:737
msgid "``\\A``"
msgstr "``\\A``"
#: ../Doc/howto/regex.rst:734
msgid ""
"Matches only at the start of the string. When not in :const:`MULTILINE` "
"mode, ``\\A`` and ``^`` are effectively the same. In :const:`MULTILINE` "
"mode, they're different: ``\\A`` still matches only at the beginning of the "
"string, but ``^`` may match at any location inside the string that follows a "
"newline character."
msgstr ""
#: ../Doc/howto/regex.rst:740
msgid "``\\Z``"
msgstr "``\\Z``"
#: ../Doc/howto/regex.rst:740
msgid "Matches only at the end of the string."
msgstr "Correspond uniquement à la fin d'une chaîne de caractères."
#: ../Doc/howto/regex.rst:775
msgid "``\\b``"
msgstr "``\\b``"
#: ../Doc/howto/regex.rst:743
msgid ""
"Word boundary. This is a zero-width assertion that matches only at the "
"beginning or end of a word. A word is defined as a sequence of alphanumeric "
"characters, so the end of a word is indicated by whitespace or a non-"
"alphanumeric character."
msgstr ""
#: ../Doc/howto/regex.rst:748
msgid ""
"The following example matches ``class`` only when it's a complete word; it "
"won't match when it's contained inside another word. ::"
msgstr ""
#: ../Doc/howto/regex.rst:759
msgid ""
"There are two subtleties you should remember when using this special "
"sequence. First, this is the worst collision between Python's string "
"literals and regular expression sequences. In Python's string literals, ``"
"\\b`` is the backspace character, ASCII value 8. If you're not using raw "
"strings, then Python will convert the ``\\b`` to a backspace, and your RE "
"won't match as you expect it to. The following example looks the same as our "
"previous RE, but omits the ``'r'`` in front of the RE string. ::"
msgstr ""
#: ../Doc/howto/regex.rst:773
msgid ""
"Second, inside a character class, where there's no use for this assertion, ``"
"\\b`` represents the backspace character, for compatibility with Python's "
"string literals."
msgstr ""
#: ../Doc/howto/regex.rst:780
msgid "``\\B``"
msgstr "``\\B``"
#: ../Doc/howto/regex.rst:778
msgid ""
"Another zero-width assertion, this is the opposite of ``\\b``, only matching "
"when the current position is not at a word boundary."
msgstr ""
#: ../Doc/howto/regex.rst:783
msgid "Grouping"
msgstr "Regroupement"
#: ../Doc/howto/regex.rst:785
msgid ""
"Frequently you need to obtain more information than just whether the RE "
"matched or not. Regular expressions are often used to dissect strings by "
"writing a RE divided into several subgroups which match different components "
"of interest. For example, an RFC-822 header line is divided into a header "
"name and a value, separated by a ``':'``, like this:"
msgstr ""
#: ../Doc/howto/regex.rst:798
msgid ""
"This can be handled by writing a regular expression which matches an entire "
"header line, and has one group which matches the header name, and another "
"group which matches the header's value."
msgstr ""
#: ../Doc/howto/regex.rst:802
msgid ""
"Groups are marked by the ``'('``, ``')'`` metacharacters. ``'('`` and "
"``')'`` have much the same meaning as they do in mathematical expressions; "
"they group together the expressions contained inside them, and you can "
"repeat the contents of a group with a repeating qualifier, such as ``*``, ``"
"+``, ``?``, or ``{m,n}``. For example, ``(ab)*`` will match zero or more "
"repetitions of ``ab``. ::"
msgstr ""
#: ../Doc/howto/regex.rst:813
msgid ""
"Groups indicated with ``'('``, ``')'`` also capture the starting and ending "
"index of the text that they match; this can be retrieved by passing an "
"argument to :meth:`~re.Match.group`, :meth:`~re.Match.start`, :meth:`~re."
"Match.end`, and :meth:`~re.Match.span`. Groups are numbered starting with "
"0. Group 0 is always present; it's the whole RE, so :ref:`match object "
"<match-objects>` methods all have group 0 as their default argument. Later "
"we'll see how to express groups that don't capture the span of text that "
"they match. ::"
msgstr ""
#: ../Doc/howto/regex.rst:829
msgid ""
"Subgroups are numbered from left to right, from 1 upward. Groups can be "
"nested; to determine the number, just count the opening parenthesis "
"characters, going from left to right. ::"
msgstr ""
#: ../Doc/howto/regex.rst:842
msgid ""
":meth:`~re.Match.group` can be passed multiple group numbers at a time, in "
"which case it will return a tuple containing the corresponding values for "
"those groups. ::"
msgstr ""
#: ../Doc/howto/regex.rst:848
msgid ""
"The :meth:`~re.Match.groups` method returns a tuple containing the strings "
"for all the subgroups, from 1 up to however many there are. ::"
msgstr ""
#: ../Doc/howto/regex.rst:854
msgid ""
"Backreferences in a pattern allow you to specify that the contents of an "
"earlier capturing group must also be found at the current location in the "
"string. For example, ``\\1`` will succeed if the exact contents of group 1 "
"can be found at the current position, and fails otherwise. Remember that "
"Python's string literals also use a backslash followed by numbers to allow "
"including arbitrary characters in a string, so be sure to use a raw string "
"when incorporating backreferences in a RE."
msgstr ""
#: ../Doc/howto/regex.rst:862
msgid "For example, the following RE detects doubled words in a string. ::"
msgstr ""
#: ../Doc/howto/regex.rst:868
msgid ""
"Backreferences like this aren't often useful for just searching through a "
"string --- there are few text formats which repeat data in this way --- but "
"you'll soon find out that they're *very* useful when performing string "
"substitutions."
msgstr ""
#: ../Doc/howto/regex.rst:874
msgid "Non-capturing and Named Groups"
msgstr ""
#: ../Doc/howto/regex.rst:876
msgid ""
"Elaborate REs may use many groups, both to capture substrings of interest, "
"and to group and structure the RE itself. In complex REs, it becomes "
"difficult to keep track of the group numbers. There are two features which "
"help with this problem. Both of them use a common syntax for regular "
"expression extensions, so we'll look at that first."
msgstr ""
#: ../Doc/howto/regex.rst:882
msgid ""
"Perl 5 is well known for its powerful additions to standard regular "
"expressions. For these new features the Perl developers couldn't choose new "
"single-keystroke metacharacters or new special sequences beginning with ``"
"\\`` without making Perl's regular expressions confusingly different from "
"standard REs. If they chose ``&`` as a new metacharacter, for example, old "
"expressions would be assuming that ``&`` was a regular character and "
"wouldn't have escaped it by writing ``\\&`` or ``[&]``."
msgstr ""
#: ../Doc/howto/regex.rst:889
msgid ""
"The solution chosen by the Perl developers was to use ``(?...)`` as the "
"extension syntax. ``?`` immediately after a parenthesis was a syntax error "
"because the ``?`` would have nothing to repeat, so this didn't introduce any "
"compatibility problems. The characters immediately after the ``?`` "
"indicate what extension is being used, so ``(?=foo)`` is one thing (a "
"positive lookahead assertion) and ``(?:foo)`` is something else (a non-"
"capturing group containing the subexpression ``foo``)."
msgstr ""
#: ../Doc/howto/regex.rst:897
msgid ""
"Python supports several of Perl's extensions and adds an extension syntax to "
"Perl's extension syntax. If the first character after the question mark is "
"a ``P``, you know that it's an extension that's specific to Python."
msgstr ""
#: ../Doc/howto/regex.rst:902
msgid ""
"Now that we've looked at the general extension syntax, we can return to the "
"features that simplify working with groups in complex REs."
msgstr ""
#: ../Doc/howto/regex.rst:905
msgid ""
"Sometimes you'll want to use a group to denote a part of a regular "
"expression, but aren't interested in retrieving the group's contents. You "
"can make this fact explicit by using a non-capturing group: ``(?:...)``, "
"where you can replace the ``...`` with any other regular expression. ::"
msgstr ""
#: ../Doc/howto/regex.rst:917
msgid ""
"Except for the fact that you can't retrieve the contents of what the group "
"matched, a non-capturing group behaves exactly the same as a capturing "
"group; you can put anything inside it, repeat it with a repetition "
"metacharacter such as ``*``, and nest it within other groups (capturing or "
"non-capturing). ``(?:...)`` is particularly useful when modifying an "
"existing pattern, since you can add new groups without changing how all the "
"other groups are numbered. It should be mentioned that there's no "
"performance difference in searching between capturing and non-capturing "
"groups; neither form is any faster than the other."
msgstr ""
#: ../Doc/howto/regex.rst:926
msgid ""
"A more significant feature is named groups: instead of referring to them by "
"numbers, groups can be referenced by a name."
msgstr ""
#: ../Doc/howto/regex.rst:929
msgid ""
"The syntax for a named group is one of the Python-specific extensions: ``(?"
"P<name>...)``. *name* is, obviously, the name of the group. Named groups "
"behave exactly like capturing groups, and additionally associate a name with "
"a group. The :ref:`match object <match-objects>` methods that deal with "
"capturing groups all accept either integers that refer to the group by "
"number or strings that contain the desired group's name. Named groups are "
"still given numbers, so you can retrieve information about a group in two "
"ways::"
msgstr ""
#: ../Doc/howto/regex.rst:944
msgid ""
"Named groups are handy because they let you use easily-remembered names, "
"instead of having to remember numbers. Here's an example RE from the :mod:"
"`imaplib` module::"
msgstr ""
#: ../Doc/howto/regex.rst:955
msgid ""
"It's obviously much easier to retrieve ``m.group('zonem')``, instead of "
"having to remember to retrieve group 9."
msgstr ""
#: ../Doc/howto/regex.rst:958
msgid ""
"The syntax for backreferences in an expression such as ``(...)\\1`` refers "
"to the number of the group. There's naturally a variant that uses the group "
"name instead of the number. This is another Python extension: ``(?P=name)`` "
"indicates that the contents of the group called *name* should again be "
"matched at the current point. The regular expression for finding doubled "
"words, ``\\b(\\w+)\\s+\\1\\b`` can also be written as ``\\b(?P<word>\\w+)\\s"
"+(?P=word)\\b``::"
msgstr ""
#: ../Doc/howto/regex.rst:971
msgid "Lookahead Assertions"
msgstr ""
#: ../Doc/howto/regex.rst:973
msgid ""
"Another zero-width assertion is the lookahead assertion. Lookahead "
"assertions are available in both positive and negative form, and look like "
"this:"
msgstr ""
#: ../Doc/howto/regex.rst:981
msgid "``(?=...)``"
msgstr "``(?=...)``"
#: ../Doc/howto/regex.rst:977
msgid ""
"Positive lookahead assertion. This succeeds if the contained regular "
"expression, represented here by ``...``, successfully matches at the current "
"location, and fails otherwise. But, once the contained expression has been "
"tried, the matching engine doesn't advance at all; the rest of the pattern "
"is tried right where the assertion started."
msgstr ""
#: ../Doc/howto/regex.rst:986
msgid "``(?!...)``"
msgstr "``(?!...)``"
#: ../Doc/howto/regex.rst:984
msgid ""
"Negative lookahead assertion. This is the opposite of the positive "
"assertion; it succeeds if the contained expression *doesn't* match at the "
"current position in the string."
msgstr ""
#: ../Doc/howto/regex.rst:988
msgid ""
"To make this concrete, let's look at a case where a lookahead is useful. "
"Consider a simple pattern to match a filename and split it apart into a base "
"name and an extension, separated by a ``.``. For example, in ``news.rc``, "
"``news`` is the base name, and ``rc`` is the filename's extension."
msgstr ""
#: ../Doc/howto/regex.rst:993
msgid "The pattern to match this is quite simple:"
msgstr "Le motif de correspondance est plutôt simple: "
#: ../Doc/howto/regex.rst:995
msgid "``.*[.].*$``"
msgstr ""
#: ../Doc/howto/regex.rst:997
msgid ""
"Notice that the ``.`` needs to be treated specially because it's a "
"metacharacter, so it's inside a character class to only match that specific "
"character. Also notice the trailing ``$``; this is added to ensure that all "
"the rest of the string must be included in the extension. This regular "
"expression matches ``foo.bar`` and ``autoexec.bat`` and ``sendmail.cf`` and "
"``printers.conf``."
msgstr ""
#: ../Doc/howto/regex.rst:1004
msgid ""
"Now, consider complicating the problem a bit; what if you want to match "
"filenames where the extension is not ``bat``? Some incorrect attempts:"
msgstr ""
#: ../Doc/howto/regex.rst:1007
msgid ""
"``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by "
"requiring that the first character of the extension is not a ``b``. This is "
"wrong, because the pattern also doesn't match ``foo.bar``."
msgstr ""
#: ../Doc/howto/regex.rst:1011
msgid "``.*[.]([^b]..|.[^a].|..[^t])$``"
msgstr ""
#: ../Doc/howto/regex.rst:1013
msgid ""
"The expression gets messier when you try to patch up the first solution by "
"requiring one of the following cases to match: the first character of the "
"extension isn't ``b``; the second character isn't ``a``; or the third "
"character isn't ``t``. This accepts ``foo.bar`` and rejects ``autoexec."
"bat``, but it requires a three-letter extension and won't accept a filename "
"with a two-letter extension such as ``sendmail.cf``. We'll complicate the "
"pattern again in an effort to fix it."
msgstr ""
#: ../Doc/howto/regex.rst:1021
msgid "``.*[.]([^b].?.?|.[^a]?.?|..?[^t]?)$``"
msgstr ""
#: ../Doc/howto/regex.rst:1023
msgid ""
"In the third attempt, the second and third letters are all made optional in "
"order to allow matching extensions shorter than three characters, such as "
"``sendmail.cf``."
msgstr ""
#: ../Doc/howto/regex.rst:1027
msgid ""
"The pattern's getting really complicated now, which makes it hard to read "
"and understand. Worse, if the problem changes and you want to exclude both "
"``bat`` and ``exe`` as extensions, the pattern would get even more "
"complicated and confusing."
msgstr ""
#: ../Doc/howto/regex.rst:1032
msgid "A negative lookahead cuts through all this confusion:"
msgstr ""
#: ../Doc/howto/regex.rst:1034
msgid ""
"``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression "
"``bat`` doesn't match at this point, try the rest of the pattern; if ``bat"
"$`` does match, the whole pattern will fail. The trailing ``$`` is required "
"to ensure that something like ``sample.batch``, where the extension only "
"starts with ``bat``, will be allowed. The ``[^.]*`` makes sure that the "
"pattern works when there are multiple dots in the filename."
msgstr ""
#: ../Doc/howto/regex.rst:1041
msgid ""
"Excluding another filename extension is now easy; simply add it as an "
"alternative inside the assertion. The following pattern excludes filenames "
"that end in either ``bat`` or ``exe``:"
msgstr ""
#: ../Doc/howto/regex.rst:1045
msgid "``.*[.](?!bat$|exe$)[^.]*$``"
msgstr ""
#: ../Doc/howto/regex.rst:1049
msgid "Modifying Strings"
msgstr ""
#: ../Doc/howto/regex.rst:1051
msgid ""
"Up to this point, we've simply performed searches against a static string. "
"Regular expressions are also commonly used to modify strings in various "
"ways, using the following pattern methods:"
msgstr ""
#: ../Doc/howto/regex.rst:1058
msgid "``split()``"
msgstr ""
#: ../Doc/howto/regex.rst:1058
msgid "Split the string into a list, splitting it wherever the RE matches"
msgstr ""
"Découpe la chaîne de caractère en liste, la découpant partout où la RE "
"correspond"
#: ../Doc/howto/regex.rst:1061
msgid "``sub()``"
msgstr ""
#: ../Doc/howto/regex.rst:1061
msgid ""
"Find all substrings where the RE matches, and replace them with a different "
"string"
msgstr ""
"Rechercher toutes les sous-chaînes de caractères où correspond la RE et les "
"substituer par une chaîne de caractères différente "
#: ../Doc/howto/regex.rst:1064
msgid "``subn()``"
msgstr ""
#: ../Doc/howto/regex.rst:1064
msgid ""
"Does the same thing as :meth:`!sub`, but returns the new string and the "
"number of replacements"
msgstr ""
#: ../Doc/howto/regex.rst:1071
msgid "Splitting Strings"
msgstr ""
#: ../Doc/howto/regex.rst:1073
msgid ""
"The :meth:`~re.Pattern.split` method of a pattern splits a string apart "
"wherever the RE matches, returning a list of the pieces. It's similar to "
"the :meth:`~str.split` method of strings but provides much more generality "
"in the delimiters that you can split by; string :meth:`!split` only supports "
"splitting by whitespace or by a fixed string. As you'd expect, there's a "
"module-level :func:`re.split` function, too."
msgstr ""
#: ../Doc/howto/regex.rst:1084
msgid ""
"Split *string* by the matches of the regular expression. If capturing "
"parentheses are used in the RE, then their contents will also be returned as "
"part of the resulting list. If *maxsplit* is nonzero, at most *maxsplit* "
"splits are performed."
msgstr ""
#: ../Doc/howto/regex.rst:1089
msgid ""
"You can limit the number of splits made, by passing a value for *maxsplit*. "
"When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the "
"remainder of the string is returned as the final element of the list. In "
"the following example, the delimiter is any sequence of non-alphanumeric "
"characters. ::"
msgstr ""
#: ../Doc/howto/regex.rst:1101
msgid ""
"Sometimes you're not only interested in what the text between delimiters is, "
"but also need to know what the delimiter was. If capturing parentheses are "
"used in the RE, then their values are also returned as part of the list. "
"Compare the following calls::"
msgstr ""
#: ../Doc/howto/regex.rst:1113
msgid ""
"The module-level function :func:`re.split` adds the RE to be used as the "
"first argument, but is otherwise the same. ::"
msgstr ""
#: ../Doc/howto/regex.rst:1125
msgid "Search and Replace"
msgstr "Recherche et Substitution"
#: ../Doc/howto/regex.rst:1127
msgid ""
"Another common task is to find all the matches for a pattern, and replace "
"them with a different string. The :meth:`~re.Pattern.sub` method takes a "
"replacement value, which can be either a string or a function, and the "
"string to be processed."
msgstr ""
#: ../Doc/howto/regex.rst:1134
msgid ""
"Returns the string obtained by replacing the leftmost non-overlapping "
"occurrences of the RE in *string* by the replacement *replacement*. If the "
"pattern isn't found, *string* is returned unchanged."
msgstr ""
#: ../Doc/howto/regex.rst:1138
msgid ""
"The optional argument *count* is the maximum number of pattern occurrences "
"to be replaced; *count* must be a non-negative integer. The default value "
"of 0 means to replace all occurrences."
msgstr ""
#: ../Doc/howto/regex.rst:1142
msgid ""
"Here's a simple example of using the :meth:`~re.Pattern.sub` method. It "
"replaces colour names with the word ``colour``::"
msgstr ""
#: ../Doc/howto/regex.rst:1151
msgid ""
"The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-"
"tuple containing the new string value and the number of replacements that "
"were performed::"
msgstr ""
#: ../Doc/howto/regex.rst:1160
msgid ""
"Empty matches are replaced only when they're not adjacent to a previous "
"empty match. ::"
msgstr ""
#: ../Doc/howto/regex.rst:1167
msgid ""
"If *replacement* is a string, any backslash escapes in it are processed. "
"That is, ``\\n`` is converted to a single newline character, ``\\r`` is "
"converted to a carriage return, and so forth. Unknown escapes such as ``"
"\\&`` are left alone. Backreferences, such as ``\\6``, are replaced with the "
"substring matched by the corresponding group in the RE. This lets you "
"incorporate portions of the original text in the resulting replacement "
"string."
msgstr ""
#: ../Doc/howto/regex.rst:1174
msgid ""
"This example matches the word ``section`` followed by a string enclosed in "
"``{``, ``}``, and changes ``section`` to ``subsection``::"
msgstr ""
#: ../Doc/howto/regex.rst:1181
msgid ""
"There's also a syntax for referring to named groups as defined by the ``(?"
"P<name>...)`` syntax. ``\\g<name>`` will use the substring matched by the "
"group named ``name``, and ``\\g<number>`` uses the corresponding group "
"number. ``\\g<2>`` is therefore equivalent to ``\\2``, but isn't ambiguous "
"in a replacement string such as ``\\g<2>0``. (``\\20`` would be interpreted "
"as a reference to group 20, not a reference to group 2 followed by the "
"literal character ``'0'``.) The following substitutions are all equivalent, "
"but use all three variations of the replacement string. ::"
msgstr ""
#: ../Doc/howto/regex.rst:1198
msgid ""
"*replacement* can also be a function, which gives you even more control. If "
"*replacement* is a function, the function is called for every non-"
"overlapping occurrence of *pattern*. On each call, the function is passed "
"a :ref:`match object <match-objects>` argument for the match and can use "
"this information to compute the desired replacement string and return it."
msgstr ""
#: ../Doc/howto/regex.rst:1204
msgid ""
"In the following example, the replacement function translates decimals into "
"hexadecimal::"
msgstr ""
#: ../Doc/howto/regex.rst:1216
msgid ""
"When using the module-level :func:`re.sub` function, the pattern is passed "
"as the first argument. The pattern may be provided as an object or as a "
"string; if you need to specify regular expression flags, you must either use "
"a pattern object as the first parameter, or use embedded modifiers in the "
"pattern string, e.g. ``sub(\"(?i)b+\", \"x\", \"bbbb BBBB\")`` returns ``'x "
"x'``."
msgstr ""
#: ../Doc/howto/regex.rst:1224
msgid "Common Problems"
msgstr "Problèmes courants"
#: ../Doc/howto/regex.rst:1226
msgid ""
"Regular expressions are a powerful tool for some applications, but in some "
"ways their behaviour isn't intuitive and at times they don't behave the way "
"you may expect them to. This section will point out some of the most common "
"pitfalls."
msgstr ""
#: ../Doc/howto/regex.rst:1232
msgid "Use String Methods"
msgstr ""
#: ../Doc/howto/regex.rst:1234
msgid ""
"Sometimes using the :mod:`re` module is a mistake. If you're matching a "
"fixed string, or a single character class, and you're not using any :mod:"
"`re` features such as the :const:`~re.IGNORECASE` flag, then the full power "
"of regular expressions may not be required. Strings have several methods for "
"performing operations with fixed strings and they're usually much faster, "
"because the implementation is a single small C loop that's been optimized "
"for the purpose, instead of the large, more generalized regular expression "
"engine."
msgstr ""
#: ../Doc/howto/regex.rst:1242
msgid ""
"One example might be replacing a single fixed string with another one; for "
"example, you might replace ``word`` with ``deed``. :func:`re.sub` seems "
"like the function to use for this, but consider the :meth:`~str.replace` "
"method. Note that :meth:`!replace` will also replace ``word`` inside words, "
"turning ``swordfish`` into ``sdeedfish``, but the naive RE ``word`` would "
"have done that, too. (To avoid performing the substitution on parts of "
"words, the pattern would have to be ``\\bword\\b``, in order to require that "
"``word`` have a word boundary on either side. This takes the job beyond :"
"meth:`!replace`'s abilities.)"
msgstr ""
#: ../Doc/howto/regex.rst:1251
msgid ""
"Another common task is deleting every occurrence of a single character from "
"a string or replacing it with another single character. You might do this "
"with something like ``re.sub('\\n', ' ', S)``, but :meth:`~str.translate` is "
"capable of doing both tasks and will be faster than any regular expression "
"operation can be."
msgstr ""
#: ../Doc/howto/regex.rst:1257
msgid ""
"In short, before turning to the :mod:`re` module, consider whether your "
"problem can be solved with a faster and simpler string method."
msgstr ""
#: ../Doc/howto/regex.rst:1262
msgid "match() versus search()"
msgstr ""
#: ../Doc/howto/regex.rst:1264
msgid ""
"The :func:`~re.match` function only checks if the RE matches at the "
"beginning of the string while :func:`~re.search` will scan forward through "
"the string for a match. It's important to keep this distinction in mind. "
"Remember, :func:`!match` will only report a successful match which will "
"start at 0; if the match wouldn't start at zero, :func:`!match` will *not* "
"report it. ::"
msgstr ""
#: ../Doc/howto/regex.rst:1275
msgid ""
"On the other hand, :func:`~re.search` will scan forward through the string, "
"reporting the first match it finds. ::"
msgstr ""
#: ../Doc/howto/regex.rst:1283
msgid ""
"Sometimes you'll be tempted to keep using :func:`re.match`, and just add ``."
"*`` to the front of your RE. Resist this temptation and use :func:`re."
"search` instead. The regular expression compiler does some analysis of REs "
"in order to speed up the process of looking for a match. One such analysis "
"figures out what the first character of a match must be; for example, a "
"pattern starting with ``Crow`` must match starting with a ``'C'``. The "
"analysis lets the engine quickly scan through the string looking for the "
"starting character, only trying the full match if a ``'C'`` is found."
msgstr ""
#: ../Doc/howto/regex.rst:1292
msgid ""
"Adding ``.*`` defeats this optimization, requiring scanning to the end of "
"the string and then backtracking to find a match for the rest of the RE. "
"Use :func:`re.search` instead."
msgstr ""
#: ../Doc/howto/regex.rst:1298
msgid "Greedy versus Non-Greedy"
msgstr ""
#: ../Doc/howto/regex.rst:1300
msgid ""
"When repeating a regular expression, as in ``a*``, the resulting action is "
"to consume as much of the pattern as possible. This fact often bites you "
"when you're trying to match a pair of balanced delimiters, such as the angle "
"brackets surrounding an HTML tag. The naive pattern for matching a single "
"HTML tag doesn't work because of the greedy nature of ``.*``. ::"
msgstr ""
#: ../Doc/howto/regex.rst:1314
msgid ""
"The RE matches the ``'<'`` in ``'<html>'``, and the ``.*`` consumes the rest "
"of the string. There's still more left in the RE, though, and the ``>`` "
"can't match at the end of the string, so the regular expression engine has "
"to backtrack character by character until it finds a match for the ``>``. "
"The final match extends from the ``'<'`` in ``'<html>'`` to the ``'>'`` in "
"``'</title>'``, which isn't what you want."
msgstr ""
#: ../Doc/howto/regex.rst:1321
msgid ""
"In this case, the solution is to use the non-greedy qualifiers ``*?``, ``+?"
"``, ``??``, or ``{m,n}?``, which match as *little* text as possible. In the "
"above example, the ``'>'`` is tried immediately after the first ``'<'`` "
"matches, and when it fails, the engine advances a character at a time, "
"retrying the ``'>'`` at every step. This produces just the right result::"
msgstr ""
#: ../Doc/howto/regex.rst:1330
msgid ""
"(Note that parsing HTML or XML with regular expressions is painful. Quick-"
"and-dirty patterns will handle common cases, but HTML and XML have special "
"cases that will break the obvious regular expression; by the time you've "
"written a regular expression that handles all of the possible cases, the "
"patterns will be *very* complicated. Use an HTML or XML parser module for "
"such tasks.)"
msgstr ""
#: ../Doc/howto/regex.rst:1338
msgid "Using re.VERBOSE"
msgstr "Utilisez re.VERBOSE"
#: ../Doc/howto/regex.rst:1340
msgid ""
"By now you've probably noticed that regular expressions are a very compact "
"notation, but they're not terribly readable. REs of moderate complexity can "
"become lengthy collections of backslashes, parentheses, and metacharacters, "
"making them difficult to read and understand."
msgstr ""
#: ../Doc/howto/regex.rst:1345
msgid ""
"For such REs, specifying the :const:`re.VERBOSE` flag when compiling the "
"regular expression can be helpful, because it allows you to format the "
"regular expression more clearly."
msgstr ""
#: ../Doc/howto/regex.rst:1349
msgid ""
"The ``re.VERBOSE`` flag has several effects. Whitespace in the regular "
"expression that *isn't* inside a character class is ignored. This means "
"that an expression such as ``dog | cat`` is equivalent to the less readable "
"``dog|cat``, but ``[a b]`` will still match the characters ``'a'``, ``'b'``, "
"or a space. In addition, you can also put comments inside a RE; comments "
"extend from a ``#`` character to the next newline. When used with triple-"
"quoted strings, this enables REs to be formatted more neatly::"
msgstr ""
#: ../Doc/howto/regex.rst:1366
msgid "This is far more readable than::"
msgstr "Ceci est beaucoup plus lisible que::"
#: ../Doc/howto/regex.rst:1372
msgid "Feedback"
msgstr "Retour"
#: ../Doc/howto/regex.rst:1374
msgid ""
"Regular expressions are a complicated topic. Did this document help you "
"understand them? Were there parts that were unclear, or Problems you "
"encountered that weren't covered here? If so, please send suggestions for "
"improvements to the author."
msgstr ""
"Les expressions régulières sont un sujet compliqué. Est-ce que ce document "
"vous a aidé à les comprendre ? Des parties ne sont pas claires, ou des "
"problèmes que vous avez rencontrés ne sont pas traités ici ? Si tel est le "
"cas, merci d'envoyer vos suggestions d'améliorations à l'auteur."
#: ../Doc/howto/regex.rst:1379
msgid ""
"The most complete book on regular expressions is almost certainly Jeffrey "
"Friedl's Mastering Regular Expressions, published by O'Reilly. "
"Unfortunately, it exclusively concentrates on Perl and Java's flavours of "
"regular expressions, and doesn't contain any Python material at all, so it "
"won't be useful as a reference for programming in Python. (The first "
"edition covered Python's now-removed :mod:`!regex` module, which won't help "
"you much.) Consider checking it out from your library."
msgstr ""
"Le livre le plus complet sur les expressions régulières est certainement "
"Mastering Regular Expressions de Jeffrey Friedl, publié par O'Reilly. "
"Malheureusement, il se concentre sur les déclinaisons Perl et Java des "
"expressions régulières et ne contient aucun contenu pour Python; il n'est "
"donc pas utile d'en faire référence pour la programmation Python. (La "
"première édition traitée du module Python:mod:`!regex`, maintenant supprimé, "
"ce qui ne vous aidera pas beaucoup.) Pensez à le retirer de votre "
"bibliothèque."