diff --git a/library/re.po b/library/re.po index aa52d6c9a1..bbcadef1fa 100644 --- a/library/re.po +++ b/library/re.po @@ -1190,7 +1190,7 @@ msgstr "``\\Z``" #: ../../library/re.rst:673 msgid "The same as ``\\z``. For compatibility with old Python versions." -msgstr "" +msgstr "和 ``\\z`` 相同。為了與舊版的 Python 相容而保留。" #: ../../library/re.rst:689 msgid "" @@ -1277,15 +1277,16 @@ msgid "" "Flag constants are now instances of :class:`RegexFlag`, which is a subclass " "of :class:`enum.IntFlag`." msgstr "" +"Flag 常數現在是 :class:`RegexFlag` 的實例,其為 :class:`enum.IntFlag` 的子類別。" #: ../../library/re.rst:742 msgid "" "An :class:`enum.IntFlag` class containing the regex options listed below." -msgstr "" +msgstr "包含下列正規表示式選項的一個 :class:`enum.IntFlag` 類別。" #: ../../library/re.rst:744 msgid "- added to ``__all__``" -msgstr "" +msgstr "- 新增至 ``__all__``" #: ../../library/re.rst:749 msgid "" @@ -1294,10 +1295,13 @@ msgid "" "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" +"(字串)模式有意義,並且在位元組模式中會被忽略。" #: ../../library/re.rst:753 msgid "Corresponds to the inline flag ``(?a)``." -msgstr "" +msgstr "對應到內嵌旗標 ``(?a)``。" #: ../../library/re.rst:757 msgid "" @@ -1307,14 +1311,17 @@ msgid "" "patterns. :py:const:`~re.UNICODE` and the inline flag ``(?u)`` are similarly " "redundant." msgstr "" +"為了向後相容,:py:const:`~re.U` 旗標仍然存在,但是在 Python 3 中是多餘的,因為" +"對於 ``str`` 模式,匹配預設是 Unicode,並且不允許位元組模式進行 Unicode 匹配。" +":py:const:`~re.UNICODE` 和內嵌旗標 ``(?u)`` 也是類似的冗餘。" #: ../../library/re.rst:766 msgid "Display debug information about compiled expression." -msgstr "" +msgstr "顯示關於已編譯表示式的偵錯資訊。" #: ../../library/re.rst:768 msgid "No corresponding inline flag." -msgstr "" +msgstr "沒有對應的內嵌旗標。" #: ../../library/re.rst:774 msgid "" @@ -1324,10 +1331,14 @@ 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]`` 這樣的表示式也會匹配小寫字母。完整的 " +"Unicode 匹配(例如 ``Ü`` 匹配 ``ü``)也能正常運作,除非使用了 :py:const:`~re.ASCII` 旗標" +"來停用非 ASCII 的匹配。除非也使用了 :py:const:`~re.LOCALE` 旗標,否則目前的區域設定不會改" +"變這個旗標的效果。" #: ../../library/re.rst:782 msgid "Corresponds to the inline flag ``(?i)``." -msgstr "" +msgstr "對應到內嵌旗標 ``(?i)``。" #: ../../library/re.rst:784 msgid "" @@ -1339,6 +1350,10 @@ msgid "" "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,無點的小寫拉丁字母 i)、'ſ' (U+017F,拉丁小寫長 s)和 'K' (U+212A,開爾文符號)。" +"如果使用了 :py:const:`~re.ASCII` 旗標,則只會匹配字母 'a' 到 'z' 和 'A' 到 'Z'。" #: ../../library/re.rst:795 msgid "" @@ -1346,10 +1361,12 @@ msgid "" "dependent on the current locale. This flag can be used only with bytes " "patterns." msgstr "" +"使 ``\\w``、``\\W``、``\\b``、``\\B`` 和不區分大小寫的匹配依賴於目前的區域設定。" +"這個旗標只能用在位元組模式中。" #: ../../library/re.rst:799 msgid "Corresponds to the inline flag ``(?L)``." -msgstr "" +msgstr "對應到內嵌旗標 ``(?L)``。" #: ../../library/re.rst:803 msgid "" @@ -1359,12 +1376,16 @@ msgid "" "for Unicode (str) patterns and it is able to handle different locales and " "languages." msgstr "" +"不建議使用這個旗標;請考慮使用 Unicode 匹配。區域設定機制非常不可靠,因為它一次只" +"處理一種「文化」,並且只適用於 8 位元的區域設定。Unicode 匹配在 Unicode(字串)模式中預設是" +"啟用的,並且能夠處理不同的區域設定和語言。" #: ../../library/re.rst:810 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` 只能用在位元組模式中,並且與 :py:const:`~re.ASCII` 不相容。" #: ../../library/re.rst:814 msgid "" @@ -1372,6 +1393,8 @@ msgid "" "longer depend on the locale at compile time. Only the locale at matching " "time affects the result of matching." msgstr "" +"使用 :py:const:`~re.LOCALE` 旗標的已編譯正規表示式物件不再依賴於編譯時的區域設定。" +"只有匹配時的區域設定會影響匹配的結果。" #: ../../library/re.rst:823 msgid "" @@ -1383,10 +1406,14 @@ 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:830 msgid "Corresponds to the inline flag ``(?m)``." -msgstr "" +msgstr "對應到內嵌旗標 ``(?m)``。" #: ../../library/re.rst:834 msgid "" @@ -1395,6 +1422,8 @@ msgid "" "will be conditionally ORed with other flags. Example of use as a default " "value::" msgstr "" +"表示沒有應用任何旗標,值為 ``0``。這個旗標可以用作函式關鍵字引數的預設值,或是作為" +"一個基底值,將會有條件地與其他旗標進行 OR 運算。作為預設值使用的範例: ::" #: ../../library/re.rst:839 msgid "" @@ -1409,10 +1438,12 @@ 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:850 msgid "Corresponds to the inline flag ``(?s)``." -msgstr "" +msgstr "對應到內嵌旗標 ``(?s)``。" #: ../../library/re.rst:856 msgid "" @@ -1420,11 +1451,13 @@ msgid "" "This flag is therefore redundant with **no effect** and is only kept for " "backward compatibility." msgstr "" +"在 Python 3 中,Unicode 字元在 ``str`` 模式中預設會被匹配。因此這個旗標是多餘的," +"**沒有任何效果**,並且僅為了向後相容而保留。" #: ../../library/re.rst:861 msgid "" "See :py:const:`~re.ASCII` to restrict matching to ASCII characters instead." -msgstr "" +msgstr "請參閱 :py:const:`~re.ASCII` 以將匹配限制為 ASCII 字元。" #: ../../library/re.rst:868 msgid "" @@ -1438,12 +1471,18 @@ msgid "" "characters from the leftmost such ``#`` through the end of the line are " "ignored." msgstr "" +"這個旗標透過讓你在視覺上分隔模式的邏輯區塊並添加註解,使你能夠撰寫看起來更好且更易讀的正" +"規表示式。模式中的空白會被忽略,除非在字元類別中,或是前面有一個未跳脫的" +"反斜線,或是在像是 ``*?``、``(?:`` 或 ``(?P<...>`` 這樣的標記中。例如,``(? :``" +" 和 ``* ?`` 是不允許的。當一行包含一個不在字元類別中且前面沒有未跳脫反斜線的 ``#`` " +"時,從最左邊的這個 ``#`` 到行尾的所有字元都會被忽略。" #: ../../library/re.rst:878 msgid "" "This means that the two following regular expression objects that match a " "decimal number are functionally equal::" msgstr "" +"這表示下面兩個匹配十進位數字的正規表示式物件在功能上是相等的: ::" #: ../../library/re.rst:881 msgid "" @@ -1452,10 +1491,14 @@ msgid "" " \\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:886 msgid "Corresponds to the inline flag ``(?x)``." -msgstr "" +msgstr "對應到內嵌旗標 ``(?x)``。" #: ../../library/re.rst:890 msgid "Functions" @@ -1652,7 +1695,7 @@ msgstr "" #: ../../library/re.rst:1010 ../../library/re.rst:1121 msgid "Added the optional flags argument." -msgstr "新增可選的旗標引數。" +msgstr "新增可選旗標引數。" #: ../../library/re.rst:1013 msgid "" @@ -1973,17 +2016,19 @@ msgstr "" #: ../../library/re.rst:1238 msgid "Regular Expression Objects" -msgstr "" +msgstr "正規表示式物件" #: ../../library/re.rst:1242 msgid "Compiled regular expression object returned by :func:`re.compile`." -msgstr "" +msgstr "由 :func:`re.compile` 回傳的已編譯正規表示式物件。" #: ../../library/re.rst:1244 msgid "" ":py:class:`re.Pattern` supports ``[]`` to indicate a Unicode (str) or bytes " "pattern. See :ref:`types-genericalias`." msgstr "" +":py:class:`re.Pattern` 支援 ``[]`` 以表示 Unicode(字串)或位元組模式。請參閱 " +":ref:`types-genericalias`。" #: ../../library/re.rst:1250 msgid "" @@ -1993,6 +2038,8 @@ 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:1255 msgid "" @@ -2002,6 +2049,9 @@ 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:1261 msgid "" @@ -2012,6 +2062,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:1268 msgid "" @@ -2020,6 +2074,10 @@ msgid "" "\n" ">>> pattern.search(\"dog\", 1) # No match; search doesn't include the \"d\"" msgstr "" +">>> pattern = re.compile(\"d\")\n" +">>> pattern.search(\"dog\") # 在索引 0 處匹配\n" +"\n" +">>> pattern.search(\"dog\", 1) # 無匹配;搜尋不包含 \"d\"" #: ../../library/re.rst:1276 msgid "" @@ -2028,12 +2086,15 @@ msgid "" "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:1281 ../../library/re.rst:1299 msgid "" "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:1284 msgid "" @@ -2044,12 +2105,18 @@ msgid "" "\"dog\".\n" "" msgstr "" +">>> pattern = re.compile(\"o\")\n" +">>> pattern.match(\"dog\") # 無匹配,因為 \"o\" 不在 \"dog\" 的開頭。\n" +">>> pattern.match(\"dog\", 1) # 匹配,因為 \"o\" 是 \"dog\" 的第二個字元。\n" +"" #: ../../library/re.rst:1289 msgid "" "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:1295 msgid "" @@ -2057,6 +2124,8 @@ 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* 與此正規表示式匹配,則回傳對應的 :class:`~re.Match`。如果字串" +"與模式不匹配,則回傳 ``None``;請注意,這與零長度匹配不同。" #: ../../library/re.rst:1302 msgid "" @@ -2068,10 +2137,15 @@ msgid "" ">>> pattern.fullmatch(\"doggie\", 1, 3) # Matches within given limits.\n" "" msgstr "" +">>> pattern = re.compile(\"o[gh]\")\n" +">>> pattern.fullmatch(\"dog\") # 無匹配,因為 \"o\" 不在 \"dog\" 的開頭。\n" +">>> pattern.fullmatch(\"ogre\") # 無匹配,因為整個字串不匹配。\n" +">>> pattern.fullmatch(\"doggie\", 1, 3) # 在給定限制內匹配。\n" +"" #: ../../library/re.rst:1313 msgid "Identical to the :func:`split` function, using the compiled pattern." -msgstr "" +msgstr "和 :func:`split` 函式相同,使用已編譯的模式。" #: ../../library/re.rst:1318 msgid "" @@ -2079,6 +2153,8 @@ msgid "" "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:1325 msgid "" @@ -2086,14 +2162,16 @@ msgid "" "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:1332 msgid "Identical to the :func:`sub` function, using the compiled pattern." -msgstr "" +msgstr "和 :func:`sub` 函式相同,使用已編譯的模式。" #: ../../library/re.rst:1337 msgid "Identical to the :func:`subn` function, using the compiled pattern." -msgstr "" +msgstr "和 :func:`subn` 函式相同,使用已編譯的模式。" #: ../../library/re.rst:1342 msgid "" @@ -2102,10 +2180,12 @@ msgid "" "implicit flags such as :py:const:`~re.UNICODE` if the pattern is a Unicode " "string." msgstr "" +"正規表示式匹配旗標。這是傳遞給 :func:`.compile` 的旗標、模式中的任何 ``(?...)`` " +"內嵌旗標以及隱含旗標(例如如果模式是 Unicode 字串則為 :py:const:`~re.UNICODE`)的組合。" #: ../../library/re.rst:1349 msgid "The number of capturing groups in the pattern." -msgstr "" +msgstr "模式中捕獲群組的數量。" #: ../../library/re.rst:1354 msgid "" @@ -2113,16 +2193,19 @@ msgid "" "group numbers. The dictionary is empty if no symbolic groups were used in " "the pattern." msgstr "" +"一個字典,將任何由 ``(?P)`` 定義的符號群組名稱對映到群組編號。如果模式中未使用符號群組,則字典為空。" #: ../../library/re.rst:1361 msgid "The pattern string from which the pattern object was compiled." -msgstr "" +msgstr "從中編譯出模式物件的模式字串。" #: ../../library/re.rst:1364 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` 的支援。已編譯的正規表示式物件" +"被視為不可分割的 (atomic)。" #: ../../library/re.rst:1372 msgid "Match Objects"