Content-Length: 62106 | pFad | http://github.com/python/python-docs-zh-tw/pull/1000.patch
thub.com
From c5a38b48302ee105342f31d655d7665a26ef31df Mon Sep 17 00:00:00 2001
From: Matt Wang
Date: Sat, 28 Jun 2025 03:28:58 +0800
Subject: [PATCH] wip
---
library/re.po | 635 ++++++++++++++++++++++++++++++++++++++------------
1 file changed, 488 insertions(+), 147 deletions(-)
diff --git a/library/re.po b/library/re.po
index 7b0935d915..cd2cc87101 100644
--- a/library/re.po
+++ b/library/re.po
@@ -8,9 +8,9 @@ msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-06-27 07:36+0000\n"
-"PO-Revision-Date: 2023-09-16 14:49+0800\n"
-"Last-Translator: Adrian Liaw \n"
+"POT-Creation-Date: 2025-06-28 03:19+0800\n"
+"PO-Revision-Date: 2025-06-28 03:32+0800\n"
+"Last-Translator: Matt Wang \n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
@@ -18,7 +18,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Poedit 3.3.2\n"
+"X-Generator: Poedit 3.6\n"
#: ../../library/re.rst:2
msgid ":mod:`!re` --- Regular expression operations"
@@ -36,12 +36,12 @@ msgstr "此模組提供類似於 Perl 中正規表示式的配對操作。"
#: ../../library/re.rst:17
msgid ""
-"Both patterns and strings to be searched can be Unicode strings (:class:"
-"`str`) as well as 8-bit strings (:class:`bytes`). However, Unicode strings "
-"and 8-bit strings cannot be mixed: that is, you cannot match a Unicode "
-"string with a bytes pattern or vice-versa; similarly, when asking for a "
-"substitution, the replacement string must be of the same type as both the "
-"pattern and the search string."
+"Both patterns and strings to be searched can be Unicode strings "
+"(:class:`str`) as well as 8-bit strings (:class:`bytes`). However, Unicode "
+"strings and 8-bit strings cannot be mixed: that is, you cannot match a "
+"Unicode string with a bytes pattern or vice-versa; similarly, when asking "
+"for a substitution, the replacement string must be of the same type as both "
+"the pattern and the search string."
msgstr ""
"被搜尋的模式 (pattern) 與字串可以是 Unicode 字串 (:class:`str`),也可以是 8-"
"bit 字串 (:class:`bytes`)。然而,Unicode 字串和 8-bit 字串不能混用:也就是,"
@@ -200,10 +200,10 @@ msgid ""
"string, and in :const:`MULTILINE` mode also matches before a newline. "
"``foo`` matches both 'foo' and 'foobar', while the regular expression "
"``foo$`` matches only 'foo'. More interestingly, searching for ``foo.$`` in "
-"``'foo1\\nfoo2\\n'`` matches 'foo2' normally, but 'foo1' in :const:"
-"`MULTILINE` mode; searching for a single ``$`` in ``'foo\\n'`` will find two "
-"(empty) matches: one just before the newline, and one at the end of the "
-"string."
+"``'foo1\\nfoo2\\n'`` matches 'foo2' normally, but 'foo1' "
+"in :const:`MULTILINE` mode; searching for a single ``$`` in ``'foo\\n'`` "
+"will find two (empty) matches: one just before the newline, and one at the "
+"end of the string."
msgstr ""
#: ../../library/re.rst:125
@@ -398,12 +398,12 @@ msgstr ""
#: ../../library/re.rst:273
msgid ""
-"Characters that are not within a range can be matched by :dfn:"
-"`complementing` the set. If the first character of the set is ``'^'``, all "
-"the characters that are *not* in the set will be matched. For example, "
-"``[^5]`` will match any character except ``'5'``, and ``[^^]`` will match "
-"any character except ``'^'``. ``^`` has no special meaning if it's not the "
-"first character in the set."
+"Characters that are not within a range can be matched "
+"by :dfn:`complementing` the set. If the first character of the set is "
+"``'^'``, all the characters that are *not* in the set will be matched. For "
+"example, ``[^5]`` will match any character except ``'5'``, and ``[^^]`` will "
+"match any character except ``'^'``. ``^`` has no special meaning if it's "
+"not the first character in the set."
msgstr ""
#: ../../library/re.rst:280
@@ -579,13 +579,13 @@ msgid ""
"Attempts to match ``...`` as if it was a separate regular expression, and if "
"successful, continues to match the rest of the pattern following it. If the "
"subsequent pattern fails to match, the stack can only be unwound to a point "
-"*before* the ``(?>...)`` because once exited, the expression, known as an :"
-"dfn:`atomic group`, has thrown away all stack points within itself. Thus, "
-"``(?>.*).`` would never match anything because first the ``.*`` would match "
-"all characters possible, then, having nothing left to match, the final ``.`` "
-"would fail to match. Since there are no stack points saved in the Atomic "
-"Group, and there is no stack point before it, the entire expression would "
-"thus fail to match."
+"*before* the ``(?>...)`` because once exited, the expression, known as "
+"an :dfn:`atomic group`, has thrown away all stack points within itself. "
+"Thus, ``(?>.*).`` would never match anything because first the ``.*`` would "
+"match all characters possible, then, having nothing left to match, the final "
+"``.`` would fail to match. Since there are no stack points saved in the "
+"Atomic Group, and there is no stack point before it, the entire expression "
+"would thus fail to match."
msgstr ""
#: ../../library/re.rst:416
@@ -713,8 +713,8 @@ msgid ""
"length, meaning that ``abc`` or ``a|b`` are allowed, but ``a*`` and ``a{3,4}"
"`` are not. Note that patterns which start with positive lookbehind "
"assertions will not match at the beginning of the string being searched; you "
-"will most likely want to use the :func:`search` function rather than the :"
-"func:`match` function:"
+"will most likely want to use the :func:`search` function rather than "
+"the :func:`match` function:"
msgstr ""
#: ../../library/re.rst:489
@@ -807,9 +807,9 @@ msgstr ""
#: ../../library/re.rst:559
msgid ""
"The default word characters in Unicode (str) patterns are Unicode "
-"alphanumerics and the underscore, but this can be changed by using the :py:"
-"const:`~re.ASCII` flag. Word boundaries are determined by the current locale "
-"if the :py:const:`~re.LOCALE` flag is used."
+"alphanumerics and the underscore, but this can be changed by using "
+"the :py:const:`~re.ASCII` flag. Word boundaries are determined by the "
+"current locale if the :py:const:`~re.LOCALE` flag is used."
msgstr ""
#: ../../library/re.rst:567
@@ -889,10 +889,10 @@ msgstr "``\\s``"
#: ../../library/re.rst:618
msgid ""
-"Matches Unicode whitespace characters (as defined by :py:meth:`str."
-"isspace`). This includes ``[ \\t\\n\\r\\f\\v]``, and also many other "
-"characters, for example the non-breaking spaces mandated by typography rules "
-"in many languages."
+"Matches Unicode whitespace characters (as defined "
+"by :py:meth:`str.isspace`). This includes ``[ \\t\\n\\r\\f\\v]``, and also "
+"many other characters, for example the non-breaking spaces mandated by "
+"typography rules in many languages."
msgstr ""
#: ../../library/re.rst:622
@@ -951,8 +951,8 @@ msgstr "``\\W``"
#: ../../library/re.rst:656
msgid ""
"Matches any character which is not a word character. This is the opposite of "
-"``\\w``. By default, matches non-underscore (``_``) characters for which :py:"
-"meth:`str.isalnum` returns ``False``."
+"``\\w``. By default, matches non-underscore (``_``) characters for "
+"which :py:meth:`str.isalnum` returns ``False``."
msgstr ""
#: ../../library/re.rst:661
@@ -1043,49 +1043,66 @@ msgid "Flags"
msgstr "旗標"
#: ../../library/re.rst:732
+#, fuzzy
msgid ""
"Flag constants are now instances of :class:`RegexFlag`, which is a subclass "
"of :class:`enum.IntFlag`."
msgstr ""
+"Flag 常數現在是 :class:`RegexFlag` 的實例,而 :class:`enum.IntFlag` "
+"是 :class:`enum.IntFlag` 的子類別。"
#: ../../library/re.rst:739
+#, fuzzy
msgid ""
"An :class:`enum.IntFlag` class containing the regex options listed below."
-msgstr ""
+msgstr "一個 :class:`enum.IntFlag` 類別包含下列 regex 選項。"
#: ../../library/re.rst:741
msgid "- added to ``__all__``"
-msgstr ""
+msgstr "- 新增至 ``__all__``"
#: ../../library/re.rst:746
+#, fuzzy
msgid ""
"Make ``\\w``, ``\\W``, ``\\b``, ``\\B``, ``\\d``, ``\\D``, ``\\s`` and "
"``\\S`` perform ASCII-only matching instead of full Unicode matching. This "
"is only meaningful for Unicode (str) patterns, and is ignored for bytes "
"patterns."
msgstr ""
+"使 ``\\w``、``\\W``、``\\b``、``\\B``、``\\d``、``\\D``、``\\s`` 和 ``\\S` 只"
+"執行 ASCII 匹配,而不是完整的 Unicode 匹配。 這只對 Unicode (str) 模式有意"
+"義,對 bytes 模式則忽略。"
#: ../../library/re.rst:750
+#, fuzzy
msgid "Corresponds to the inline flag ``(?a)``."
-msgstr ""
+msgstr "對應內聯旗標 ``(?a)``。"
#: ../../library/re.rst:754
+#, fuzzy
msgid ""
"The :py:const:`~re.U` flag still exists for backward compatibility, but is "
"redundant in Python 3 since matches are Unicode by default for ``str`` "
-"patterns, and Unicode matching isn't allowed for bytes patterns. :py:const:"
-"`~re.UNICODE` and the inline flag ``(?u)`` are similarly redundant."
+"patterns, and Unicode matching isn't allowed for bytes "
+"patterns. :py:const:`~re.UNICODE` and the inline flag ``(?u)`` are similarly "
+"redundant."
msgstr ""
+":py:const:`~re.U` 旗標仍然存在是為了向後相容,但在 Python 3 中是多餘的,因為"
+"對於 ``str`` 模式,預設匹配是 Unicode,而對於 bytes 模式,Unicode 匹配是不允"
+"許的。 :py:const:`~re.UNICODE` 和 inline 旗標 ``(?u)`` 也是類似多餘的。"
#: ../../library/re.rst:763
+#, fuzzy
msgid "Display debug information about compiled expression."
-msgstr ""
+msgstr "顯示有關已編譯表達式的除錯資訊。"
#: ../../library/re.rst:765
+#, fuzzy
msgid "No corresponding inline flag."
-msgstr ""
+msgstr "沒有對應的內嵌旗標。"
#: ../../library/re.rst:771
+#, fuzzy
msgid ""
"Perform case-insensitive matching; expressions like ``[A-Z]`` will also "
"match lowercase letters. Full Unicode matching (such as ``Ü`` matching "
@@ -1093,34 +1110,50 @@ msgid ""
"non-ASCII matches. The current locale does not change the effect of this "
"flag unless the :py:const:`~re.LOCALE` flag is also used."
msgstr ""
+"執行不區分大小寫的匹配;像``[A-Z]``這類的表達式也會匹配小寫字母。除非使"
+"用 :py:const:`~re.ASCII` 旗標禁止非 ASCII 匹配,否則完整的 Unicode 匹配 (例"
+"如 ``Ü`` 匹配 ``ü``)也會生效。除非同時使用 :py:const:`~re.LOCALE` 旗標,否則"
+"目前的 locale 不會改變這個旗標的效果。"
#: ../../library/re.rst:779
+#, fuzzy
msgid "Corresponds to the inline flag ``(?i)``."
-msgstr ""
+msgstr "對應內聯旗標 ``(?i)``。"
#: ../../library/re.rst:781
+#, fuzzy
msgid ""
"Note that 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 'K' (U+212A, Kelvin sign). If "
+"letter I with dot above), 'ı' (U+0131, Latin small letter dotless i), 'ſ' "
+"(U+017F, Latin small letter long s) and 'K' (U+212A, Kelvin sign). If "
"the :py:const:`~re.ASCII` flag is used, only letters 'a' to 'z' and 'A' to "
"'Z' are matched."
msgstr ""
+"請注意,當 Unicode 模式 ``[a-z]`` 或 ``[A-Z]`` 與 :const:`IGNORECASE` 旗標結"
+"合使用時,它們會匹配 52 個 ASCII 字母和另外 4 個非 ASCII 字母:'İ' (U+0130, "
+"拉丁大寫字母 I 上面有點)、'ı' (U+0131, 拉丁小寫字母 dotless i)、'ſ' (U+017F, "
+"拉丁小寫字母 long s) 和 'K' (U+212A, 開爾文符號)。如果使"
+"用 :py:const:`~re.ASCII` 旗標,則只會匹配 'a' 到 'z' 和 'A' 到 'Z' 的字母。"
#: ../../library/re.rst:792
+#, fuzzy
msgid ""
"Make ``\\w``, ``\\W``, ``\\b``, ``\\B`` and case-insensitive matching "
"dependent on the current locale. This flag can be used only with bytes "
"patterns."
msgstr ""
+"使``\\w```, ``\\W``, ``\\b``,``\\B``和大小寫不敏感匹配取決於當前的locale。此"
+"旗標只能用於 bytes 模式。"
#: ../../library/re.rst:796
+#, fuzzy
msgid "Corresponds to the inline flag ``(?L)``."
-msgstr ""
+msgstr "對應內聯旗標 ``(?L)``。"
#: ../../library/re.rst:800
+#, fuzzy
msgid ""
"This flag is discouraged; consider Unicode matching instead. The locale "
"mechanism is very unreliable as it only handles one \"culture\" at a time "
@@ -1128,21 +1161,30 @@ msgid ""
"for Unicode (str) patterns and it is able to handle different locales and "
"languages."
msgstr ""
+"不鼓勵使用此旗標;請考慮改用 Unicode 匹配。locale 機制非常不可靠,因為它一次"
+"只能處理一種「文化」,而且只適用於 8 位元的 locale。對於 Unicode (str) 模式,"
+"預設會啟用 Unicode 匹配,它能夠處理不同的區域和語言。"
#: ../../library/re.rst:807
+#, fuzzy
msgid ""
":py:const:`~re.LOCALE` can be used only with bytes patterns and is not "
"compatible with :py:const:`~re.ASCII`."
msgstr ""
+":py:const:`~re.LOCALE` 只能用於 bytes 模式,與 :py:const:`~re.ASCII` 不相容。"
#: ../../library/re.rst:811
+#, fuzzy
msgid ""
"Compiled regular expression objects with the :py:const:`~re.LOCALE` flag no "
"longer depend on the locale at compile time. Only the locale at matching "
"time affects the result of matching."
msgstr ""
+"使用 :py:const:`~re.LOCALE` 旗標的編譯正則表達式物件不再依賴編譯時的 locale。"
+"只有匹配時的 locale 才會影響匹配結果。"
#: ../../library/re.rst:820
+#, fuzzy
msgid ""
"When specified, the pattern character ``'^'`` matches at the beginning of "
"the string and at the beginning of each line (immediately following each "
@@ -1152,48 +1194,67 @@ msgid ""
"only at the end of the string and immediately before the newline (if any) at "
"the end of the string."
msgstr ""
+"當指定時,樣式字元 ``'^「`` 會在字串的開頭和每一行的開頭(緊接在每個新線之"
+"後)匹配;樣式字元 ``」$'`` 會在字串的結尾和每一行的結尾(緊接在每個新線之"
+"前)匹配。 預設情況下,``'^「`` 只在字串的開頭匹配,``」$'`` 只在字串的結尾"
+"和緊接在字串結尾的換行符(如果有)之前匹配。"
#: ../../library/re.rst:827
+#, fuzzy
msgid "Corresponds to the inline flag ``(?m)``."
-msgstr ""
+msgstr "對應內聯旗標 ``(?m)``。"
#: ../../library/re.rst:831
+#, fuzzy
msgid ""
"Indicates no flag being applied, the value is ``0``. This flag may be used "
"as a default value for a function keyword argument or as a base value that "
"will be conditionally ORed with other flags. Example of use as a default "
"value::"
msgstr ""
+"表示沒有套用旗標,值為 ``0``。 此旗標可用作函式關鍵字參數的預設值,或用作將"
+"與其他旗標進行有條件 OR 的基本值。 作為預設值使用的範例::"
#: ../../library/re.rst:836
msgid ""
"def myfunc(text, flag=re.NOFLAG):\n"
" return re.match(text, flag)"
msgstr ""
+"def myfunc(text, flag=re.NOFLAG):\n"
+" return re.match(text, flag)"
#: ../../library/re.rst:844
+#, fuzzy
msgid ""
"Make the ``'.'`` special character match any character at all, including a "
"newline; without this flag, ``'.'`` will match anything *except* a newline."
msgstr ""
+"使 ``'.'`` 特殊字元匹配任何字元,包括換行符;如果沒有這個旗標,``」.'` 將匹配"
+"除換行符以外的任何字元。"
#: ../../library/re.rst:847
+#, fuzzy
msgid "Corresponds to the inline flag ``(?s)``."
-msgstr ""
+msgstr "對應內聯旗標 ``(?s)``。"
#: ../../library/re.rst:853
+#, fuzzy
msgid ""
"In Python 3, Unicode characters are matched by default for ``str`` patterns. "
"This flag is therefore redundant with **no effect** and is only kept for "
"backward compatibility."
msgstr ""
+"在 Python 3 中,Unicode 字元預設是匹配 ``str`` 模式。因此,這個旗號是多餘的,"
+"沒有**作用,保留它只是為了向後相容。"
#: ../../library/re.rst:858
+#, fuzzy
msgid ""
"See :py:const:`~re.ASCII` to restrict matching to ASCII characters instead."
-msgstr ""
+msgstr "請參閱 :py:const:`~re.ASCII` 來限制匹配為 ASCII 字元。"
#: ../../library/re.rst:865
+#, fuzzy
msgid ""
"This flag allows you to write regular expressions that look nicer and are "
"more readable by allowing you to visually separate logical sections of the "
@@ -1205,24 +1266,36 @@ msgid ""
"characters from the leftmost such ``#`` through the end of the line are "
"ignored."
msgstr ""
+"此旗標允許您視覺上分隔模式的邏輯部分並加入註解,讓您寫出的正則表 達式看起來更"
+"美觀、更易讀。除非是在字元類別中、或前面有未括開的反斜線、或在像 ``*?``、"
+"``(?:`` 或 ``(?P<...>``這類的符號中,否則模式中的空白會被忽略。例如,``(?:`` "
+"和 ``*?``` 是不允許的。當一行包含不屬於某個字元類別的 ``#`` 且前面沒有反斜線"
+"時,從最左邊的這個 ``#`` 到該行結尾的所有字元都會被忽略。"
#: ../../library/re.rst:875
+#, fuzzy
msgid ""
"This means that the two following regular expression objects that match a "
"decimal number are functionally equal::"
-msgstr ""
+msgstr "這表示以下兩個匹配十進位數字的正則表達式物件在功能上是相等的::"
#: ../../library/re.rst:878
+#, fuzzy
msgid ""
"a = re.compile(r\"\"\"\\d + # the integral part\n"
" \\. # the decimal point\n"
" \\d * # some fractional digits\"\"\", re.X)\n"
"b = re.compile(r\"\\d+\\.\\d*\")"
msgstr ""
+"a = re.compile(r\"\"\"\\d + # 整數部分\n"
+" \\. # 小數點\n"
+" \\d * # 一些小數位\"\"\"\", re.X)\n"
+"b = re.compile(r\"\\d+\\.\\d*\")"
#: ../../library/re.rst:883
+#, fuzzy
msgid "Corresponds to the inline flag ``(?x)``."
-msgstr ""
+msgstr "對應內聯旗標 ``(?x)``。"
#: ../../library/re.rst:887
msgid "Functions"
@@ -1231,11 +1304,12 @@ msgstr "函式"
#: ../../library/re.rst:891
msgid ""
"Compile a regular expression pattern into a :ref:`regular expression object "
-"`, which can be used for matching using its :func:`~Pattern."
-"match`, :func:`~Pattern.search` and other methods, described below."
+"`, which can be used for matching using "
+"its :func:`~Pattern.match`, :func:`~Pattern.search` and other methods, "
+"described below."
msgstr ""
-"將正規表示式模式編譯成\\ :ref:`正規表示式物件 `,可以使用它的 :"
-"func:`~Pattern.match`、:func:`~Pattern.search` 等方法來匹配,如下所述。"
+"將正規表示式模式編譯成\\ :ref:`正規表示式物件 `,可以使用它"
+"的 :func:`~Pattern.match`、:func:`~Pattern.search` 等方法來匹配,如下所述。"
#: ../../library/re.rst:896 ../../library/re.rst:928 ../../library/re.rst:946
#: ../../library/re.rst:957 ../../library/re.rst:1003 ../../library/re.rst:1037
@@ -1280,10 +1354,10 @@ msgstr ""
#: ../../library/re.rst:915
msgid ""
-"The compiled versions of the most recent patterns passed to :func:`re."
-"compile` and the module-level matching functions are cached, so programs "
-"that use only a few regular expressions at a time needn't worry about "
-"compiling regular expressions."
+"The compiled versions of the most recent patterns passed "
+"to :func:`re.compile` and the module-level matching functions are cached, so "
+"programs that use only a few regular expressions at a time needn't worry "
+"about compiling regular expressions."
msgstr ""
"傳遞給 :func:`re.compile` 之最新模式的編譯版本和模組層級匹配函式都會被快取,"
"因此一次僅使用幾個正規表示式的程式不必去擔心編譯正規表示式。"
@@ -1291,14 +1365,14 @@ msgstr ""
#: ../../library/re.rst:923
msgid ""
"Scan through *string* looking for the first location where the regular "
-"expression *pattern* produces a match, and return a corresponding :class:"
-"`~re.Match`. Return ``None`` if no position in the string matches the "
-"pattern; note that this is different from finding a zero-length match at "
-"some point in the string."
+"expression *pattern* produces a match, and return a "
+"corresponding :class:`~re.Match`. Return ``None`` if no position in the "
+"string matches the pattern; note that this is different from finding a zero-"
+"length match at some point in the string."
msgstr ""
-"掃描 *string* 以尋找正規表示式 *pattern* 產生匹配的第一個位置,並回傳對應的 :"
-"class:`~re.Match`。如果字串中沒有與模式匹配的位置則回傳 ``None``;請注意,這"
-"與在字串中的某個點查找零長度匹配不同。"
+"掃描 *string* 以尋找正規表示式 *pattern* 產生匹配的第一個位置,並回傳對應"
+"的 :class:`~re.Match`。如果字串中沒有與模式匹配的位置則回傳 ``None``;請注"
+"意,這與在字串中的某個點查找零長度匹配不同。"
#: ../../library/re.rst:935
msgid ""
@@ -1307,9 +1381,9 @@ msgid ""
"``None`` if the string does not match the pattern; note that this is "
"different from a zero-length match."
msgstr ""
-"如果 *string* 開頭的零個或多個字元與正規表示式 *pattern* 匹配,則回傳對應的 :"
-"class:`~re.Match`。如果字串與模式不匹配,則回傳 ``None``;請注意,這與零長度"
-"匹配不同。"
+"如果 *string* 開頭的零個或多個字元與正規表示式 *pattern* 匹配,則回傳對應"
+"的 :class:`~re.Match`。如果字串與模式不匹配,則回傳 ``None``;請注意,這與零"
+"長度匹配不同。"
#: ../../library/re.rst:940
msgid ""
@@ -1333,8 +1407,9 @@ msgid ""
"corresponding :class:`~re.Match`. Return ``None`` if the string does not "
"match the pattern; note that this is different from a zero-length match."
msgstr ""
-"如果整個 *string* 與正規表示式 *pattern* 匹配,則回傳對應的 :class:`~re."
-"Match`。如果字串與模式不匹配,則回傳 ``None``;請注意,這與零長度匹配不同。"
+"如果整個 *string* 與正規表示式 *pattern* 匹配,則回傳對應"
+"的 :class:`~re.Match`。如果字串與模式不匹配,則回傳 ``None``;請注意,這與零"
+"長度匹配不同。"
#: ../../library/re.rst:966
msgid ""
@@ -1519,8 +1594,8 @@ msgid ""
"...\n"
">>> re.sub('-{1,2}', dashrepl, 'pro----gram-files')\n"
"'pro--gram files'\n"
-">>> re.sub(r'\\sAND\\s', ' & ', 'Baked Beans And Spam', flags=re."
-"IGNORECASE)\n"
+">>> re.sub(r'\\sAND\\s', ' & ', 'Baked Beans And Spam', "
+"flags=re.IGNORECASE)\n"
"'Baked Beans & Spam'"
msgstr ""
">>> def dashrepl(matchobj):\n"
@@ -1529,8 +1604,8 @@ msgstr ""
"...\n"
">>> re.sub('-{1,2}', dashrepl, 'pro----gram-files')\n"
"'pro--gram files'\n"
-">>> re.sub(r'\\sAND\\s', ' & ', 'Baked Beans And Spam', flags=re."
-"IGNORECASE)\n"
+">>> re.sub(r'\\sAND\\s', ' & ', 'Baked Beans And Spam', "
+"flags=re.IGNORECASE)\n"
"'Baked Beans & Spam'"
#: ../../library/re.rst:1091
@@ -1588,8 +1663,8 @@ msgid ""
"Unknown escapes in *repl* consisting of ``'\\'`` and an ASCII letter now are "
"errors. An empty match can occur immediately after a non-empty match."
msgstr ""
-"由 ``'\\'`` 和一個 ASCII 字母組成之 *repl* 中的未知轉義符現在為錯誤。"
-"非空匹配後可以緊接著出現空匹配。"
+"由 ``'\\'`` 和一個 ASCII 字母組成之 *repl* 中的未知轉義符現在為錯誤。非空匹配"
+"後可以緊接著出現空匹配。"
#: ../../library/re.rst:1133
msgid ""
@@ -1737,20 +1812,26 @@ msgstr ""
"``PatternError`` 最初被命名為 ``error``;後者為了向後相容性而被保留為別名。"
#: ../../library/re.rst:1235
+#, fuzzy
msgid "Regular Expression Objects"
-msgstr ""
+msgstr "正規表達物件"
#: ../../library/re.rst:1239
+#, fuzzy
msgid "Compiled regular expression object returned by :func:`re.compile`."
-msgstr ""
+msgstr "由 :func:`re.compile` 回傳的已編譯正規表示式物件。"
#: ../../library/re.rst:1241
+#, fuzzy
msgid ""
":py:class:`re.Pattern` supports ``[]`` to indicate a Unicode (str) or bytes "
"pattern. See :ref:`types-genericalias`."
msgstr ""
+":py:class:`re.Pattern` 支援 ``[]`` 來表示 Unicode (str) 或 bytes 模式。請參"
+"閱 :ref:`types-genericalias`。"
#: ../../library/re.rst:1247
+#, fuzzy
msgid ""
"Scan through *string* looking for the first location where this regular "
"expression produces a match, and return a corresponding :class:`~re.Match`. "
@@ -1758,8 +1839,12 @@ msgid ""
"this is different from finding a zero-length match at some point in the "
"string."
msgstr ""
+"掃描 *string* 找尋此正規表示式產生匹配的第一個位置,並回傳相對應"
+"的 :class:`~re.Match`。如果字串中沒有任何位置與模式匹配,則回傳 ``None``;請"
+"注意,這與在字串中的某一點找到零長度的匹配不同。"
#: ../../library/re.rst:1252
+#, fuzzy
msgid ""
"The optional second parameter *pos* gives an index in the string where the "
"search is to start; it defaults to ``0``. This is not completely equivalent "
@@ -1767,8 +1852,12 @@ msgid ""
"beginning of the string and at positions just after a newline, but not "
"necessarily at the index where the search is to start."
msgstr ""
+"可選的第二個參數 *pos* 給出在字串中要開始搜尋的索引;預設為 ``0``。 這並不完"
+"全等同於分割字串;```'^'``模式符會匹配字串真正的開頭和換行符之後的位置,但不"
+"一定會匹配搜尋開始的索引。"
#: ../../library/re.rst:1258
+#, fuzzy
msgid ""
"The optional parameter *endpos* limits how far the string will be searched; "
"it will be as if the string is *endpos* characters long, so only the "
@@ -1777,6 +1866,10 @@ msgid ""
"compiled regular expression object, ``rx.search(string, 0, 50)`` is "
"equivalent to ``rx.search(string[:50], 0)``. ::"
msgstr ""
+"可選參數 *endpos* 會限制字串被搜尋的距離;它會像字串的長度是 *endpos* 字元一"
+"樣,所以只有從 *pos* 到 ``endpos - 1`` 的字元會被搜尋到匹配。 如果 *endpos* "
+"小於 *pos*,則不會找到匹配;否則,如果 *rx* 是編譯過的正規表示式物件,"
+"``rx.search(string, 0, 50)`` 等同於``rx.search(string[:50], 0)``。 ::"
#: ../../library/re.rst:1265
msgid ""
@@ -1787,18 +1880,24 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1273
+#, fuzzy
msgid ""
"If zero or more characters at the *beginning* of *string* match this regular "
"expression, return a corresponding :class:`~re.Match`. Return ``None`` if "
"the string does not match the pattern; note that this is different from a "
"zero-length match."
msgstr ""
+"如果在 *string* 的 *beginning* 有 0 個或以上的字元符合這個正規表示式,就會回"
+"傳一個相對應的 :class:`~re.Match`。如果字串不符合模式,則回傳 ``None``;請注"
+"意,這與長度為零的匹配不同。"
#: ../../library/re.rst:1278 ../../library/re.rst:1296
+#, fuzzy
msgid ""
-"The optional *pos* and *endpos* parameters have the same meaning as for the :"
-"meth:`~Pattern.search` method. ::"
+"The optional *pos* and *endpos* parameters have the same meaning as for "
+"the :meth:`~Pattern.search` method. ::"
msgstr ""
+"可選的 *pos* 和 *endpos* 參數與 :meth:`~Pattern.search` 方法的意義相同。 ::"
#: ../../library/re.rst:1281
msgid ""
@@ -1811,17 +1910,23 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1286
+#, fuzzy
msgid ""
-"If you want to locate a match anywhere in *string*, use :meth:`~Pattern."
-"search` instead (see also :ref:`search-vs-match`)."
+"If you want to locate a match anywhere in *string*, "
+"use :meth:`~Pattern.search` instead (see also :ref:`search-vs-match`)."
msgstr ""
+"如果要在 *string* 的任何地方找出匹配,請使用 :meth:`~Pattern.search` 來代替 "
+"(請參閱 :ref:`search-vs-match`)。"
#: ../../library/re.rst:1292
+#, fuzzy
msgid ""
"If the whole *string* matches this regular expression, return a "
"corresponding :class:`~re.Match`. Return ``None`` if the string does not "
"match the pattern; note that this is different from a zero-length match."
msgstr ""
+"如果整個 *string* 符合這個正則表達式,回傳相應的 :class:`~re.Match`。 如果字"
+"串不符合模式,則回傳 ``None``;請注意,這與零長度匹配不同。"
#: ../../library/re.rst:1299
msgid ""
@@ -1835,69 +1940,97 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1310
+#, fuzzy
msgid "Identical to the :func:`split` function, using the compiled pattern."
-msgstr ""
+msgstr "與 :func:`split` 函式相同,使用編譯的模式。"
#: ../../library/re.rst:1315
+#, fuzzy
msgid ""
"Similar to the :func:`findall` function, using the compiled pattern, but "
"also accepts optional *pos* and *endpos* parameters that limit the search "
"region like for :meth:`search`."
msgstr ""
+"類似於 :func:`findall` 函式,使用編譯的模式,但也接受可選的 *pos* 和 "
+"*endpos* 參數,像 :meth:`search` 一樣限制搜尋區域。"
#: ../../library/re.rst:1322
+#, fuzzy
msgid ""
"Similar to the :func:`finditer` function, using the compiled pattern, but "
"also accepts optional *pos* and *endpos* parameters that limit the search "
"region like for :meth:`search`."
msgstr ""
+"類似於 :func:`finditer` 函式,使用編譯的樣式,但也接受可選的 *pos* 和 "
+"*endpos* 參數,像 :meth:`search` 一樣限制搜尋區域。"
#: ../../library/re.rst:1329
+#, fuzzy
msgid "Identical to the :func:`sub` function, using the compiled pattern."
-msgstr ""
+msgstr "與 :func:`sub` 函式相同,使用編譯的模式。"
#: ../../library/re.rst:1334
+#, fuzzy
msgid "Identical to the :func:`subn` function, using the compiled pattern."
-msgstr ""
+msgstr "與 :func:`subn` 函式相同,使用編譯的模式。"
#: ../../library/re.rst:1339
+#, fuzzy
msgid ""
-"The regex matching flags. This is a combination of the flags given to :func:"
-"`.compile`, any ``(?...)`` inline flags in the pattern, and implicit flags "
-"such as :py:const:`~re.UNICODE` if the pattern is a Unicode string."
+"The regex matching flags. This is a combination of the flags given "
+"to :func:`.compile`, any ``(?...)`` inline flags in the pattern, and "
+"implicit flags such as :py:const:`~re.UNICODE` if the pattern is a Unicode "
+"string."
msgstr ""
+"regex 匹配标志。 這是給 :func:`.compile` 的旗標、pattern 中任何 ``(?...)`` "
+"內嵌旗標,以及隱含旗標的組合,例如 :py:const:`~re.UNICODE` (如果 pattern 是 "
+"Unicode 字串)。"
#: ../../library/re.rst:1346
+#, fuzzy
msgid "The number of capturing groups in the pattern."
-msgstr ""
+msgstr "圖樣中捕捉群組的數量。"
#: ../../library/re.rst:1351
+#, fuzzy
msgid ""
"A dictionary mapping any symbolic group names defined by ``(?P)`` to "
"group numbers. The dictionary is empty if no symbolic groups were used in "
"the pattern."
msgstr ""
+"將 ``(?P)`` 定義的任何符號群組名稱對應到群組號碼的辭典。 如果模式中沒有"
+"使用符號群組,字典為空。"
#: ../../library/re.rst:1358
+#, fuzzy
msgid "The pattern string from which the pattern object was compiled."
-msgstr ""
+msgstr "編譯模式物件的模式字串。"
#: ../../library/re.rst:1361
+#, fuzzy
msgid ""
"Added support of :func:`copy.copy` and :func:`copy.deepcopy`. Compiled "
"regular expression objects are considered atomic."
msgstr ""
+"新增對 :func:`copy.copy` 和 :func:`copy.deepcopy` 的支援。 編譯的正則表達式"
+"物件被視為原子物件。"
#: ../../library/re.rst:1369
+#, fuzzy
msgid "Match Objects"
-msgstr ""
+msgstr "匹配物件"
#: ../../library/re.rst:1371
+#, fuzzy
msgid ""
-"Match objects always have a boolean value of ``True``. Since :meth:`~Pattern."
-"match` and :meth:`~Pattern.search` return ``None`` when there is no match, "
-"you can test whether there was a match with a simple ``if`` statement::"
+"Match objects always have a boolean value of ``True``. "
+"Since :meth:`~Pattern.match` and :meth:`~Pattern.search` return ``None`` "
+"when there is no match, you can test whether there was a match with a simple "
+"``if`` statement::"
msgstr ""
+"Match 物件永遠有一個 ``True`` 的布林值。由於 :meth:`~Pattern.match` "
+"和 :meth:`~Pattern.search` 在沒有匹配時會回傳 ``None``,您可以用簡單的 ``if` "
+"語句來測試是否有匹配::"
#: ../../library/re.rst:1376
msgid ""
@@ -1910,16 +2043,21 @@ msgstr ""
" process(match)"
#: ../../library/re.rst:1382
+#, fuzzy
msgid "Match object returned by successful ``match``\\ es and ``search``\\ es."
-msgstr ""
+msgstr "由成功的 ``match``es 和 ``search``es 回傳的匹配物件。"
#: ../../library/re.rst:1384
+#, fuzzy
msgid ""
":py:class:`re.Match` supports ``[]`` to indicate a Unicode (str) or bytes "
"match. See :ref:`types-genericalias`."
msgstr ""
+":py:class:`re.Match` 支援 ``[]`` 來表示 Unicode (str) 或 bytes 匹配。請參"
+"閱 :ref:`types-genericalias`。"
#: ../../library/re.rst:1390
+#, fuzzy
msgid ""
"Return the string obtained by doing backslash substitution on the template "
"string *template*, as done by the :meth:`~Pattern.sub` method. Escapes such "
@@ -1928,8 +2066,13 @@ msgid ""
"``\\g``) are replaced by the contents of the corresponding group. The "
"backreference ``\\g<0>`` will be replaced by the entire match."
msgstr ""
+"根據 :meth:`~Pattern.sub` 方法,回傳在模板字串 *template* 上進行反斜線取代所"
+"得到的字串。轉換符如 ``\\n`` 會被轉換成適當的字元、數字反向引用 (``\\1``、"
+"``\\2``) 和命名反向引用 (``\\g<1>``、``\\g``) 會被相對應的群組內容取"
+"代。反向引用 ``\\g<0>`` 將被整個匹配內容取代。"
#: ../../library/re.rst:1403
+#, fuzzy
msgid ""
"Returns one or more subgroups of the match. If there is a single argument, "
"the result is a single string; if there are multiple arguments, the result "
@@ -1943,6 +2086,13 @@ msgid ""
"the corresponding result is ``None``. If a group is contained in a part of "
"the pattern that matched multiple times, the last match is returned. ::"
msgstr ""
+"回傳匹配的一個或多個子群組。 如果只有一個參數,則結果為單一字串;如果有多個"
+"參數,則結果為元組,每個參數有一個項目。在沒有參數的情況下,*group1* 預設為零"
+"(會回傳整個匹配結果)。如果 *groupN* 參數為零,對應的回傳值是整個匹配字串;"
+"如果它在包含範圍 [1.99],則是匹配對應括弧群組的字串。 如果群組號碼是負數或大"
+"於模式中定義的群組數,則會產生 :exc:`IndexError` 例外。如果一個群組包含在模式"
+"中沒有匹配到的部分,對應的結果是 ``None``。如果一個群組包含在模式中多次匹配的"
+"部分,則回傳最後一次匹配的結果。 ::"
#: ../../library/re.rst:1415
msgid ""
@@ -1958,16 +2108,21 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1425
+#, fuzzy
msgid ""
"If the regular expression uses the ``(?P...)`` syntax, the *groupN* "
"arguments may also be strings identifying groups by their group name. If a "
-"string argument is not used as a group name in the pattern, an :exc:"
-"`IndexError` exception is raised."
+"string argument is not used as a group name in the pattern, "
+"an :exc:`IndexError` exception is raised."
msgstr ""
+"如果正規表達式使用 ``(?P...)`` 語法,*groupN* 參數也可以是以群組名稱來"
+"識別群組的字串。 如果在模式中沒有使用字串參數作為群組名稱,則會產"
+"生 :exc:`IndexError` 例外。"
#: ../../library/re.rst:1430
+#, fuzzy
msgid "A moderately complicated example::"
-msgstr ""
+msgstr "中度複雜的範例::"
#: ../../library/re.rst:1432
msgid ""
@@ -1986,8 +2141,9 @@ msgstr ""
"'Reynolds'"
#: ../../library/re.rst:1438
+#, fuzzy
msgid "Named groups can also be referred to by their index::"
-msgstr ""
+msgstr "已命名群組也可以用其索引:來參照:"
#: ../../library/re.rst:1440
msgid ""
@@ -2002,8 +2158,9 @@ msgstr ""
"'Reynolds'"
#: ../../library/re.rst:1445
+#, fuzzy
msgid "If a group matches multiple times, only the last match is accessible::"
-msgstr ""
+msgstr "如果一個群組匹配多次,則只可存取最後一個匹配的群組::"
#: ../../library/re.rst:1447
msgid ""
@@ -2013,10 +2170,11 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1454
+#, fuzzy
msgid ""
"This is identical to ``m.group(g)``. This allows easier access to an "
"individual group from a match::"
-msgstr ""
+msgstr "這與 ``m.group(g)`` 相同。 這允許更容易地從 match: 存取個別群組:"
#: ../../library/re.rst:1457
msgid ""
@@ -2030,8 +2188,9 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1465
+#, fuzzy
msgid "Named groups are supported as well::"
-msgstr ""
+msgstr "也支援命名群組::"
#: ../../library/re.rst:1467
msgid ""
@@ -2050,11 +2209,14 @@ msgstr ""
"'Newton'"
#: ../../library/re.rst:1478
+#, fuzzy
msgid ""
"Return a tuple containing all the subgroups of the match, from 1 up to "
"however many groups are in the pattern. The *default* argument is used for "
"groups that did not participate in the match; it defaults to ``None``."
msgstr ""
+"回傳一個包含所有匹配的子群組的元組數,從 1 到模式中的多少個群組。 *default* "
+"參數用於沒有參與匹配的群組;它的預設值是 ``None``。"
#: ../../library/re.rst:1482 ../../library/re.rst:1707
msgid "For example::"
@@ -2071,11 +2233,14 @@ msgstr ""
"('24', '1632')"
#: ../../library/re.rst:1488
+#, fuzzy
msgid ""
"If we make the decimal place and everything after it optional, not all "
"groups might participate in the match. These groups will default to "
"``None`` unless the *default* argument is given::"
msgstr ""
+"如果我們將小數位及之後的所有內容設定為可選,並非所有的群組都可能參與匹配。 "
+"除非給出 *default* 參數,否則這些群組將預設為 ``None``::"
#: ../../library/re.rst:1492
msgid ""
@@ -2087,11 +2252,14 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1501
+#, fuzzy
msgid ""
"Return a dictionary containing all the *named* subgroups of the match, keyed "
"by the subgroup name. The *default* argument is used for groups that did "
"not participate in the match; it defaults to ``None``. For example::"
msgstr ""
+"回傳一個字典,包含所有匹配的 *named* 子群組,以子群組名稱為關鍵。 *default* "
+"參數用於沒有參與匹配的群組;預設為 ``None``。 例如::"
#: ../../library/re.rst:1505
msgid ""
@@ -2106,6 +2274,7 @@ msgstr ""
"{'first_name': 'Malcolm', 'last_name': 'Reynolds'}"
#: ../../library/re.rst:1513
+#, fuzzy
msgid ""
"Return the indices of the start and end of the substring matched by *group*; "
"*group* defaults to zero (meaning the whole matched substring). Return "
@@ -2113,22 +2282,32 @@ msgid ""
"object *m*, and a group *g* that did contribute to the match, the substring "
"matched by group *g* (equivalent to ``m.group(g)``) is ::"
msgstr ""
+"回傳 *group* 所匹配子串的開始和結束的索引;*group* 預設為零(意指整個匹配的子"
+"串)。如果 *group* 存在,但沒有參與匹配,則回傳 ``-1``。 對於一個匹配物件 "
+"*m*,以及一個對匹配有貢獻的群組 *g*,群組 *g* 所匹配的子串 (等於 "
+"``m.group(g)``) 是 ::"
#: ../../library/re.rst:1519
msgid "m.string[m.start(g):m.end(g)]"
msgstr "m.string[m.start(g):m.end(g)]"
#: ../../library/re.rst:1521
+#, fuzzy
msgid ""
"Note that ``m.start(group)`` will equal ``m.end(group)`` if *group* matched "
-"a null string. For example, after ``m = re.search('b(c?)', 'cba')``, ``m."
-"start(0)`` is 1, ``m.end(0)`` is 2, ``m.start(1)`` and ``m.end(1)`` are both "
-"2, and ``m.start(2)`` raises an :exc:`IndexError` exception."
+"a null string. For example, after ``m = re.search('b(c?)', 'cba')``, "
+"``m.start(0)`` is 1, ``m.end(0)`` is 2, ``m.start(1)`` and ``m.end(1)`` are "
+"both 2, and ``m.start(2)`` raises an :exc:`IndexError` exception."
msgstr ""
+"請注意,如果 *group* 匹配的是空字串,``m.start(group)`` 將等於"
+"``m.end(group)``。 例如,在 ``m = re.search('b(c?)', 'cba')`` 之後, "
+"``m.start(0)`` 是 1,``m.end(0)`` 是 2,``m.start(1)`` 和 ``m.end(1)`` 都是 "
+"2,``m.start(2)`` 產生 :exc:`IndexError` 例外。"
#: ../../library/re.rst:1526
+#, fuzzy
msgid "An example that will remove *remove_this* from email addresses::"
-msgstr ""
+msgstr "將從電子郵件地址移除 *remove_this* 的範例::"
#: ../../library/re.rst:1528
msgid ""
@@ -2143,27 +2322,41 @@ msgstr ""
"'tony@tiger.net'"
#: ../../library/re.rst:1536
+#, fuzzy
msgid ""
"For a match *m*, return the 2-tuple ``(m.start(group), m.end(group))``. Note "
"that if *group* did not contribute to the match, this is ``(-1, -1)``. "
"*group* defaults to zero, the entire match."
msgstr ""
+"對於一個匹配 *m*,回傳 2-tuple ``(m.start(group),m.end(group))``。請注意,如"
+"果 *group* 對匹配沒有貢獻,這將是 ``(-1, -1)`` 。*group* 預設為零,即整個匹"
+"配。"
#: ../../library/re.rst:1543
+#, fuzzy
msgid ""
-"The value of *pos* which was passed to the :meth:`~Pattern.search` or :meth:"
-"`~Pattern.match` method of a :ref:`regex object `. This is the "
-"index into the string at which the RE engine started looking for a match."
+"The value of *pos* which was passed to the :meth:`~Pattern.search` "
+"or :meth:`~Pattern.match` method of a :ref:`regex object `. "
+"This is the index into the string at which the RE engine started looking for "
+"a match."
msgstr ""
+"傳給 :ref:`regex object ` 的 :meth:`~Pattern.search` "
+"或 :meth:`~Pattern.match` 方法的 *pos* 值。 這是 RE 引擎開始尋找匹配的字串索"
+"引。"
#: ../../library/re.rst:1550
+#, fuzzy
msgid ""
-"The value of *endpos* which was passed to the :meth:`~Pattern.search` or :"
-"meth:`~Pattern.match` method of a :ref:`regex object `. This is "
-"the index into the string beyond which the RE engine will not go."
+"The value of *endpos* which was passed to the :meth:`~Pattern.search` "
+"or :meth:`~Pattern.match` method of a :ref:`regex object `. "
+"This is the index into the string beyond which the RE engine will not go."
msgstr ""
+"傳給 :ref:`regex object ` 的 :meth:`~Pattern.search` "
+"或 :meth:`~Pattern.match` 方法的 *endpos* 值。 這是 RE 引擎不會超越的字串索"
+"引。"
#: ../../library/re.rst:1557
+#, fuzzy
msgid ""
"The integer index of the last matched capturing group, or ``None`` if no "
"group was matched at all. For example, the expressions ``(a)b``, ``((a)"
@@ -2171,42 +2364,59 @@ msgid ""
"``'ab'``, while the expression ``(a)(b)`` will have ``lastindex == 2``, if "
"applied to the same string."
msgstr ""
+"最後配對的捕捉群組的整數索引,或 ``None`` 如果沒有任何群組被配對。例如,表達"
+"式 ``(a)b``、``((a)(b))` 和 ``((ab))`如果套用在字串 `'ab'` 上,將有 "
+"``lastindex == 1``,而表達式 ``(a)(b)`如果套用在相同的字串上,將有 "
+"``lastindex == 2``。"
#: ../../library/re.rst:1566
+#, fuzzy
msgid ""
"The name of the last matched capturing group, or ``None`` if the group "
"didn't have a name, or if no group was matched at all."
msgstr ""
+"最後配對的擷取群組名稱,如果群組沒有名稱,或根本沒有配對群組,則為 ``None``。"
#: ../../library/re.rst:1572
+#, fuzzy
msgid ""
-"The :ref:`regular expression object ` whose :meth:`~Pattern."
-"match` or :meth:`~Pattern.search` method produced this match instance."
+"The :ref:`regular expression object ` "
+"whose :meth:`~Pattern.match` or :meth:`~Pattern.search` method produced this "
+"match instance."
msgstr ""
+":ref:`regular expression object `,其 :meth:`~Pattern.match` "
+"或 :meth:`~Pattern.search` 方法產生這個 match 實例。"
#: ../../library/re.rst:1578
+#, fuzzy
msgid "The string passed to :meth:`~Pattern.match` or :meth:`~Pattern.search`."
-msgstr ""
+msgstr "傳給 :meth:`~Pattern.match` 或 :meth:`~Pattern.search` 的字串。"
#: ../../library/re.rst:1581
+#, fuzzy
msgid ""
"Added support of :func:`copy.copy` and :func:`copy.deepcopy`. Match objects "
"are considered atomic."
msgstr ""
+"新增了 :func:`copy.copy` 和 :func:`copy.deepcopy` 的支援。 匹配物件被視為原"
+"子物件。"
#: ../../library/re.rst:1589
+#, fuzzy
msgid "Regular Expression Examples"
-msgstr ""
+msgstr "正規表示法範例"
#: ../../library/re.rst:1593
+#, fuzzy
msgid "Checking for a Pair"
-msgstr ""
+msgstr "檢查對子"
#: ../../library/re.rst:1595
+#, fuzzy
msgid ""
"In this example, we'll use the following helper function to display match "
"objects a little more gracefully::"
-msgstr ""
+msgstr "在本範例中,我們將使用下列輔助函式,以更優雅的方式顯示匹配物件::"
#: ../../library/re.rst:1598
msgid ""
@@ -2229,8 +2439,9 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1608
+#, fuzzy
msgid "To see if a given string is a valid hand, one could do the following::"
-msgstr ""
+msgstr "要查看給定的字串是否是有效的手,可以執行下列操作::"
#: ../../library/re.rst:1610
msgid ""
@@ -2244,11 +2455,14 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1618
+#, fuzzy
msgid ""
"That last hand, ``\"727ak\"``, contained a pair, or two of the same valued "
"cards. To match this with a regular expression, one could use backreferences "
"as such::"
msgstr ""
+"最後一手牌,``\"727ak\"``,包含一對或兩張相同價值的牌。若要使用正規表達式來匹"
+"配,可以使用反向參照,例如::"
#: ../../library/re.rst:1621
msgid ""
@@ -2261,10 +2475,13 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1628
+#, fuzzy
msgid ""
-"To find out what card the pair consists of, one could use the :meth:`~Match."
-"group` method of the match object in the following manner::"
+"To find out what card the pair consists of, one could use "
+"the :meth:`~Match.group` method of the match object in the following manner::"
msgstr ""
+"若要找出這對牌由哪張牌組成,可以使用 match 物件的 :meth:`~Match.group` 方法,"
+"方式如下::"
#: ../../library/re.rst:1631
msgid ""
@@ -2289,21 +2506,27 @@ msgid "Simulating scanf()"
msgstr "模擬 scanf()"
#: ../../library/re.rst:1651
+#, fuzzy
msgid ""
"Python does not currently have an equivalent to :c:func:`!scanf`. Regular "
-"expressions are generally more powerful, though also more verbose, than :c:"
-"func:`!scanf` format strings. The table below offers some more-or-less "
-"equivalent mappings between :c:func:`!scanf` format tokens and regular "
+"expressions are generally more powerful, though also more verbose, "
+"than :c:func:`!scanf` format strings. The table below offers some more-or-"
+"less equivalent mappings between :c:func:`!scanf` format tokens and regular "
"expressions."
msgstr ""
+"Python 目前沒有與 :c:func:`!scanf` 對等的東西。 正则表达式通常比 :c:func:`!"
+"scanf` 格式字串更强大,尽管也更啰嗦。 下表提供了 :c:func:`!scanf` 格式符號和"
+"正則表達式之間的一些或多或少等效的映射。"
#: ../../library/re.rst:1658
+#, fuzzy
msgid ":c:func:`!scanf` Token"
-msgstr ""
+msgstr ":c:func:`!scanf` 令牌"
#: ../../library/re.rst:1658
+#, fuzzy
msgid "Regular Expression"
-msgstr ""
+msgstr "正規表示法"
#: ../../library/re.rst:1660
msgid "``%c``"
@@ -2374,51 +2597,60 @@ msgid "``[-+]?(0[xX])?[\\dA-Fa-f]+``"
msgstr "``[-+]?(0[xX])?[\\dA-Fa-f]+``"
#: ../../library/re.rst:1679
+#, fuzzy
msgid "To extract the filename and numbers from a string like ::"
-msgstr ""
+msgstr "要從字串中抽取檔案名稱和數字,如::"
#: ../../library/re.rst:1681
msgid "/usr/sbin/sendmail - 0 errors, 4 warnings"
msgstr "/usr/sbin/sendmail - 0 errors, 4 warnings"
#: ../../library/re.rst:1683
+#, fuzzy
msgid "you would use a :c:func:`!scanf` format like ::"
-msgstr ""
+msgstr "您可以使用 :c:func:`!scanf` 格式,如 ::"
#: ../../library/re.rst:1685
+#, fuzzy
msgid "%s - %d errors, %d warnings"
-msgstr ""
+msgstr "%s - %d 錯誤,%d 警告"
#: ../../library/re.rst:1687
+#, fuzzy
msgid "The equivalent regular expression would be ::"
-msgstr ""
+msgstr "等效的正則表達式為 ::"
#: ../../library/re.rst:1689
+#, fuzzy
msgid "(\\S+) - (\\d+) errors, (\\d+) warnings"
-msgstr ""
+msgstr "(\\S+) - (\\d+) 錯誤, (\\d+) 警告"
#: ../../library/re.rst:1695
msgid "search() vs. match()"
msgstr "search() vs. match()"
#: ../../library/re.rst:1699
+#, fuzzy
msgid ""
"Python offers different primitive operations based on regular expressions:"
-msgstr ""
+msgstr "Python 提供了基於正則表達式的不同原始運算:"
#: ../../library/re.rst:1701
+#, fuzzy
msgid ":func:`re.match` checks for a match only at the beginning of the string"
-msgstr ""
+msgstr ":func:`re.match` 僅檢查字串開頭是否匹配"
#: ../../library/re.rst:1702
+#, fuzzy
msgid ""
":func:`re.search` checks for a match anywhere in the string (this is what "
"Perl does by default)"
-msgstr ""
+msgstr ":func:`re.search` 檢查字串中任何地方是否有匹配 (Perl 預設會這樣做)"
#: ../../library/re.rst:1704
+#, fuzzy
msgid ":func:`re.fullmatch` checks for entire string to be a match"
-msgstr ""
+msgstr ":func:`re.fullmatch` 檢查整個字串是否匹配"
#: ../../library/re.rst:1709
msgid ""
@@ -2431,10 +2663,13 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1716
+#, fuzzy
msgid ""
"Regular expressions beginning with ``'^'`` can be used with :func:`search` "
"to restrict the match at the beginning of the string::"
msgstr ""
+"以 ``'^'`` 開頭的正則表達式可與 :func:`search` 搭配使用,以限制字串開頭的匹"
+"配::"
#: ../../library/re.rst:1719
msgid ""
@@ -2445,12 +2680,16 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1724
+#, fuzzy
msgid ""
"Note however that in :const:`MULTILINE` mode :func:`match` only matches at "
"the beginning of the string, whereas using :func:`search` with a regular "
"expression beginning with ``'^'`` will match at the beginning of each "
"line. ::"
msgstr ""
+"但是請注意,在 :const:`MULTILINE` 模式中 :func:`match` 只會在字串的開頭進行匹"
+"配,而使用 :func:`search` 和以 ``'^'`` 開頭的正則表達式則會在每一行的開頭進行"
+"匹配。 ::"
#: ../../library/re.rst:1728
msgid ""
@@ -2460,22 +2699,28 @@ msgid ""
msgstr ""
#: ../../library/re.rst:1734
+#, fuzzy
msgid "Making a Phonebook"
-msgstr ""
+msgstr "製作電話簿"
#: ../../library/re.rst:1736
+#, fuzzy
msgid ""
":func:`split` splits a string into a list delimited by the passed pattern. "
"The method is invaluable for converting textual data into data structures "
"that can be easily read and modified by Python as demonstrated in the "
"following example that creates a phonebook."
msgstr ""
+":func:`split` 將一個字串分割成一個以傳入的模式為分界的列表。 這個方法對於將"
+"文字資料轉換成 Python 可以輕鬆讀取和修改的資料結構非常有價值,就像以下建立電"
+"話簿的範例所展示的一樣。"
#: ../../library/re.rst:1741
+#, fuzzy
msgid ""
"First, here is the input. Normally it may come from a file, here we are "
"using triple-quoted string syntax"
-msgstr ""
+msgstr "首先,這裡是輸入。 通常它可能來自檔案,這裡我們使用三引號字串語法"
#: ../../library/re.rst:1744
msgid ""
@@ -2496,10 +2741,13 @@ msgstr ""
"... Heather Albrecht: 548.326.4584 919 Park Place\"\"\""
#: ../../library/re.rst:1754
+#, fuzzy
msgid ""
"The entries are separated by one or more newlines. Now we convert the string "
"into a list with each nonempty line having its own entry:"
msgstr ""
+"項目之間以一個或多個換行分隔。現在我們將字串轉換成列表,每一行非空的行都有自"
+"己的項目:"
#: ../../library/re.rst:1757
msgid ""
@@ -2518,11 +2766,15 @@ msgstr ""
"'Heather Albrecht: 548.326.4584 919 Park Place']"
#: ../../library/re.rst:1767
+#, fuzzy
msgid ""
"Finally, split each entry into a list with first name, last name, telephone "
"number, and address. We use the ``maxsplit`` parameter of :func:`split` "
"because the address has spaces, our splitting pattern, in it:"
msgstr ""
+"最後,將每個項目分割為包含名、姓、電話號碼和地址的清單。 我們使"
+"用 :func:`split` 的 ``maxsplit`` 參數,因為地址中有空格,也就是我們的分割模"
+"式:"
#: ../../library/re.rst:1771
msgid ""
@@ -2539,11 +2791,14 @@ msgstr ""
"['Heather', 'Albrecht', '548.326.4584', '919 Park Place']]"
#: ../../library/re.rst:1780
+#, fuzzy
msgid ""
"The ``:?`` pattern matches the colon after the last name, so that it does "
"not occur in the result list. With a ``maxsplit`` of ``4``, we could "
"separate the house number from the street name:"
msgstr ""
+"``:?``模式會匹配姓氏後面的冒號,因此它不會出現在結果清單中。 使用 "
+"``maxsplit`` ``4```,我們可以將門牌號碼和街道名稱分開:"
#: ../../library/re.rst:1784
msgid ""
@@ -2560,16 +2815,21 @@ msgstr ""
"['Heather', 'Albrecht', '548.326.4584', '919', 'Park Place']]"
#: ../../library/re.rst:1795
+#, fuzzy
msgid "Text Munging"
-msgstr ""
+msgstr "文字萌芽"
#: ../../library/re.rst:1797
+#, fuzzy
msgid ""
":func:`sub` replaces every occurrence of a pattern with a string or the "
"result of a function. This example demonstrates using :func:`sub` with a "
"function to \"munge\" text, or randomize the order of all the characters in "
"each word of a sentence except for the first and last characters::"
msgstr ""
+":func:`sub` 用一個字串或一個函式的結果取代每一次出現的 pattern。 這個範例示"
+"範使用 :func:`sub` 與函式來 \"munge \"文字,或隨機排列句子中每個字元的順序,"
+"除了第一個和最後一個字元::"
#: ../../library/re.rst:1802
msgid ""
@@ -2596,16 +2856,21 @@ msgstr ""
"'Pofsroser Aodlambelk, plasee reoprt yuor asnebces potlmrpy.'"
#: ../../library/re.rst:1815
+#, fuzzy
msgid "Finding all Adverbs"
-msgstr ""
+msgstr "尋找所有副詞"
#: ../../library/re.rst:1817
+#, fuzzy
msgid ""
":func:`findall` matches *all* occurrences of a pattern, not just the first "
"one as :func:`search` does. For example, if a writer wanted to find all of "
"the adverbs in some text, they might use :func:`findall` in the following "
"manner::"
msgstr ""
+":func:`findall` 會匹配模式的所有*次出現,而不是像 :func:`search` 般只匹配第一"
+"次出現。 舉例來說,如果作者想要找出某些文字中所有的副詞,他們可能會以下列方"
+"式使用 :func:`findall`::"
#: ../../library/re.rst:1822
msgid ""
@@ -2618,10 +2883,12 @@ msgstr ""
"['carefully', 'quickly']"
#: ../../library/re.rst:1828
+#, fuzzy
msgid "Finding all Adverbs and their Positions"
-msgstr ""
+msgstr "尋找所有副詞及其位置"
#: ../../library/re.rst:1830
+#, fuzzy
msgid ""
"If one wants more information about all matches of a pattern than the "
"matched text, :func:`finditer` is useful as it provides :class:`~re.Match` "
@@ -2629,6 +2896,9 @@ msgid ""
"writer wanted to find all of the adverbs *and their positions* in some text, "
"they would use :func:`finditer` in the following manner::"
msgstr ""
+"如果您想要比匹配的文字更多的資料, :func:`finditer` 是有用的,因為它提"
+"供 :class:`~re.Match` 物件來取代字串。 繼續前面的範例,如果作者想要找出某些"
+"文字中所有的副詞 * 及其位置 *,他們會以下列方式使用 :func:`finditer`::"
#: ../../library/re.rst:1836
msgid ""
@@ -2645,8 +2915,9 @@ msgstr ""
"40-47: quickly"
#: ../../library/re.rst:1844
+#, fuzzy
msgid "Raw String Notation"
-msgstr ""
+msgstr "原始字串符號"
#: ../../library/re.rst:1846
msgid ""
@@ -2669,12 +2940,16 @@ msgstr ""
""
#: ../../library/re.rst:1856
+#, fuzzy
msgid ""
"When one wants to match a literal backslash, it must be escaped in the "
"regular expression. With raw string notation, this means ``r\"\\\\\"``. "
"Without raw string notation, one must use ``\"\\\\\\\\\"``, making the "
"following lines of code functionally identical::"
msgstr ""
+"當要匹配字面上的反斜線時,必須在正規表示式中轉義它。 如果使用原始字串符號,"
+"這表示 ``r\"\\\\\"``。 如果不使用原始字串符號,則必須使用 ``\"\\\\\\\\\"``,"
+"這使得以下幾行程式碼在功能上完全相同::"
#: ../../library/re.rst:1861
msgid ""
@@ -2689,24 +2964,33 @@ msgstr ""
""
#: ../../library/re.rst:1868
+#, fuzzy
msgid "Writing a Tokenizer"
-msgstr ""
+msgstr "編寫標記器"
#: ../../library/re.rst:1870
+#, fuzzy
msgid ""
"A `tokenizer or scanner `_ "
"analyzes a string to categorize groups of characters. This is a useful "
"first step in writing a compiler or interpreter."
msgstr ""
+"一個 `tokenizer 或 scanner `_ 會分析字串以將字元群分類。 這是撰寫編譯器或直譯器的第一"
+"步。"
#: ../../library/re.rst:1874
+#, fuzzy
msgid ""
"The text categories are specified with regular expressions. The technique "
"is to combine those into a single master regular expression and to loop over "
"successive matches::"
msgstr ""
+"使用正規表達式指定文字類別。 其技術是將這些內容合併為單一的主正則表達式,並"
+"循環檢查連續匹配的內容::"
#: ../../library/re.rst:1878
+#, fuzzy
msgid ""
"from typing import NamedTuple\n"
"import re\n"
@@ -2761,10 +3045,63 @@ msgid ""
"for token in tokenize(statements):\n"
" print(token)"
msgstr ""
+"從 typing 匯入 NamedTuple\n"
+"匯入 re\n"
+"\n"
+"class Token(NamedTuple):\n"
+" type: str\n"
+" value: str\n"
+" line: int\n"
+" column: int\n"
+"\n"
+"def tokenize(code):\n"
+" keywords = {'IF', 'THEN', 'ENDIF', 'FOR', 'NEXT', 'GOSUB', 'RETURN'}\n"
+" token_specification = [\n"
+" ('NUMBER', r'\\d+(\\.\\d*)?'), # 整數或十進位數字\n"
+" ('ASSIGN', r':='), # 指定運算符號\n"
+" ('END', r';'), # 語句終止符\n"
+" ('ID', r'[A-Za-z]+'), # 識別符號\n"
+" ('OP', r'[+\\-*/]'), # 算術運算符號\n"
+" ('NEWLINE',r'\\n'),#行結束符\n"
+" ('SKIP', r'[ \\t]+'), # 跳過空格和制表符\n"
+" ('MISMATCH', r'.'), # 任何其他字元\n"
+" ]\n"
+" tok_regex = '|'.join('(?P<%s>%s)' % pair for pair in "
+"token_specification)\n"
+" 行數 = 1\n"
+" line_start = 0\n"
+" for mo in re.finditer(tok_regex, code):\n"
+" kind = mo.lastgroup\n"
+" value = mo.group()\n"
+" column = mo.start() - line_start\n"
+" if kind == 'NUMBER':\n"
+" value = float(value) if '.' in value else int(value)\n"
+" elif kind == 'ID' 且 value 在關鍵字中:\n"
+" kind = value\n"
+" elif kind == 'NEWLINE':\n"
+" line_start = mo.end()\n"
+" line_num += 1\n"
+" 繼續\n"
+" elif kind == 'SKIP':\n"
+" 繼續\n"
+" elif kind == 'MISMATCH':\n"
+" raise RuntimeError(f'{value!r} unexpected on line {line_num}')\n"
+" yield Token(kind, value, line_num, column)\n"
+"\n"
+"statements = '''\n"
+" IF quantity THEN\n"
+" total := total + price * quantity;\n"
+" tax := price * 0.05;\n"
+" ENDIF;\n"
+"'''\n"
+"\n"
+"for token in tokenize(statements):\n"
+" print(token)"
#: ../../library/re.rst:1930
+#, fuzzy
msgid "The tokenizer produces the following output::"
-msgstr ""
+msgstr "tokenizer 產生以下輸出::"
#: ../../library/re.rst:1932
msgid ""
@@ -2809,12 +3146,16 @@ msgstr ""
"Token(type='END', value=';', line=5, column=9)"
#: ../../library/re.rst:1953
+#, fuzzy
msgid ""
"Friedl, Jeffrey. Mastering Regular Expressions. 3rd ed., O'Reilly Media, "
"2009. The third edition of the book no longer covers Python at all, but the "
"first edition covered writing good regular expression patterns in great "
"detail."
msgstr ""
+"Friedl, Jeffrey.Mastering Regular Expressions.第 3 版,O'Reilly Media,2009 "
+"年。這本書的第三版完全不再涵蓋 Python,但第一版非常詳盡地介紹了如何寫出好的正"
+"則表達式模式。"
#: ../../library/re.rst:99
msgid ". (dot)"
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/python/python-docs-zh-tw/pull/1000.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy