@@ -11,7 +11,7 @@ msgstr ""
11
11
"Report-Msgid-Bugs-To : \n "
12
12
"POT-Creation-Date : 2022-10-15 20:43+0000\n "
13
13
"PO-Revision-Date : 2023-05-05 12:57+0000\n "
14
- "Last-Translator : raymond <raymond727341 @gmail.com>\n "
14
+ "Last-Translator : Josix <josixwang @gmail.com>\n "
15
15
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh-tw) "
16
16
"\n "
17
17
"Language : regex\n "
@@ -975,8 +975,8 @@ msgstr ""
975
975
"你不必創建一個模式對象並調用其方法;相應的 :mod:`re` "
976
976
"模塊還提供了頂級函數,如::func:`~re.match`, :func:`~re.search`, :func:`~re."
977
977
"findall`, :func:`~re.sub`。這些函數與相應的模式方法具有相同的引數(以 RE "
978
- "字串作為第一個引數),仍然返回 ``None`` 或者是匹配對象 ( :ref:`match-objects`) "
979
- " 實例。 ::"
978
+ "字串作為第一個引數),仍然返回 ``None`` 或者是匹配物件(match object)( :ref"
979
+ ":`match-objects` ) 實例。 ::"
980
980
981
981
#: ../../howto/regex.rst:510
982
982
msgid ""
@@ -1916,19 +1916,16 @@ msgid "``subn()``"
1916
1916
msgstr "``subn()``"
1917
1917
1918
1918
#: ../../howto/regex.rst:1072
1919
- #, fuzzy
1920
1919
msgid ""
1921
1920
"Does the same thing as :meth:`!sub`, but returns the new string and the "
1922
1921
"number of replacements"
1923
- msgstr "跟 `sub()` 方法一樣,但回傳值是所產生的新字串以及替換發生的次數"
1922
+ msgstr "跟 `! sub()` 方法一樣,但回傳值是所產生的新字串以及替換發生的次數"
1924
1923
1925
1924
#: ../../howto/regex.rst:1079
1926
- #, fuzzy
1927
1925
msgid "Splitting Strings"
1928
1926
msgstr "分割字串"
1929
1927
1930
1928
#: ../../howto/regex.rst:1081
1931
- #, fuzzy
1932
1929
msgid ""
1933
1930
"The :meth:`~re.Pattern.split` method of a pattern splits a string apart "
1934
1931
"wherever the RE matches, returning a list of the pieces. It's similar to "
@@ -1937,24 +1934,24 @@ msgid ""
1937
1934
"splitting by whitespace or by a fixed string. As you'd expect, there's a "
1938
1935
"module-level :func:`re.split` function, too."
1939
1936
msgstr ""
1940
- "模式的 :meth:`~re.Pattern.split` "
1941
- "方法將字符串拆分為正則表達式匹配到的位置,返回一個列表。它類似於字串的 "
1942
- ":meth:`!split` 方法,但在可分隔符號方面提供更多通用性;字串 :meth:`!split` "
1943
- "只支援按空格或固定字元進行拆分 。預期中也有模組級別的函數::func:`re.split`。"
1937
+ ":meth:~re.Pattern.split 方法可以將符合正規表示式的部分作為分隔符將字符串拆分"
1938
+ "成多個部分,並返回一個列表。它類似於字串的 :meth:`!split` "
1939
+ "方法,但在可分隔符號方面提供更多通用性;字串 :meth:`!split` "
1940
+ "只支援按空格或固定字元進行拆分 "
1941
+ "。正如你所期望的那樣,也有模組級別的函數::func:`re.split`。"
1944
1942
1945
1943
#: ../../howto/regex.rst:1092
1946
- #, fuzzy
1947
1944
msgid ""
1948
1945
"Split *string* by the matches of the regular expression. If capturing "
1949
1946
"parentheses are used in the RE, then their contents will also be returned as "
1950
1947
"part of the resulting list. If *maxsplit* is nonzero, at most *maxsplit* "
1951
1948
"splits are performed."
1952
1949
msgstr ""
1953
- "拆分*string*,以正則表達式作匹配。若RE使用捕獲括號,將其內容也一同返回為結果"
1954
- "列表的元素。當*maxsplit*非零時,最多執行 *maxsplit* 次拆分。"
1950
+ "以正則表達式匹配結果拆分 *string* 。若 RE 使用捕獲括號(capturing "
1951
+ "parentheses),將其內容也一同返回為結果列表的元素。當 *maxsplit* 非零時,"
1952
+ "最多執行 *maxsplit* 次拆分。"
1955
1953
1956
1954
#: ../../howto/regex.rst:1097
1957
- #, fuzzy
1958
1955
msgid ""
1959
1956
"You can limit the number of splits made, by passing a value for *maxsplit*. "
1960
1957
"When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the "
@@ -1964,35 +1961,35 @@ msgid ""
1964
1961
msgstr ""
1965
1962
"你可以透過設定 *maxsplit* 參數來限制分割次數,當 *maxsplit* 值不是零時,最多"
1966
1963
"分割此數量並將字串剩餘部份作為清單的最終元素回傳。在下面的範例中,以非英文字"
1967
- "母和數字為區隔符號。 ::"
1964
+ "母和數字為區隔符號。:\n"
1965
+ "\n"
1966
+ "::"
1968
1967
1969
1968
#: ../../howto/regex.rst:1109
1970
- #, fuzzy
1971
1969
msgid ""
1972
1970
"Sometimes you're not only interested in what the text between delimiters is, "
1973
1971
"but also need to know what the delimiter was. If capturing parentheses are "
1974
1972
"used in the RE, then their values are also returned as part of the list. "
1975
1973
"Compare the following calls::"
1976
1974
msgstr ""
1977
1975
"有時你不僅對分隔符之間的文本有興趣,也需要知道該分隔符是什麼。 "
1978
- "如果在正規表示式(RE)中使用捕獲括號,那麼它們的值也作為列表的一部分返回。 "
1979
- "比較以下調用:"
1976
+ "如果在正規表示式(RE)中使用捕獲括號(capturing "
1977
+ "parentheses),那麼它們的值也作為列表的一部分返回。 比較以下調用:\n"
1978
+ "\n"
1979
+ "::"
1980
1980
1981
1981
#: ../../howto/regex.rst:1121
1982
- #, fuzzy
1983
1982
msgid ""
1984
1983
"The module-level function :func:`re.split` adds the RE to be used as the "
1985
1984
"first argument, but is otherwise the same. ::"
1986
- msgstr "模組層級函式 :func:` re.split` 新增一個參數,作為被用來作為第一個引數的正規表 "
1987
- "示式,但除此之外功能和原本相同。 "
1985
+ msgstr "模塊級別的函數 :func:re.split "
1986
+ "將要使用的正則表達式作為第一個參數添加,但其他方面與上述方法相同。:: "
1988
1987
1989
1988
#: ../../howto/regex.rst:1133
1990
- #, fuzzy
1991
1989
msgid "Search and Replace"
1992
1990
msgstr "搜尋和取代"
1993
1991
1994
1992
#: ../../howto/regex.rst:1135
1995
- #, fuzzy
1996
1993
msgid ""
1997
1994
"Another common task is to find all the matches for a pattern, and replace "
1998
1995
"them with a different string. The :meth:`~re.Pattern.sub` method takes a "
@@ -2004,51 +2001,47 @@ msgstr ""
2004
2001
"方法需要傳入替換值,可以是字串或函式,以及要處理的字串。"
2005
2002
2006
2003
#: ../../howto/regex.rst:1142
2007
- #, fuzzy
2008
2004
msgid ""
2009
2005
"Returns the string obtained by replacing the leftmost non-overlapping "
2010
2006
"occurrences of the RE in *string* by the replacement *replacement*. If the "
2011
2007
"pattern isn't found, *string* is returned unchanged."
2012
2008
msgstr ""
2013
- "回傳字串,此字串經取代來源字串 *string* "
2014
- "中最左邊且沒重複的區段符合所提供的正規表示式 RE 所產生之符合 REPLACEMENT "
2015
- "的內容。若未找到該模式,則回傳原始 *string* 字串。"
2009
+ "回傳將 *string* 中最左邊的非重疊出現的正規表示式(RE)取代為 *replacement* "
2010
+ "所得到的字串。如果找不到符合的模式,則回傳未更改的 *string*。"
2016
2011
2017
2012
#: ../../howto/regex.rst:1146
2018
- #, fuzzy
2019
2013
msgid ""
2020
2014
"The optional argument *count* is the maximum number of pattern occurrences "
2021
2015
"to be replaced; *count* must be a non-negative integer. The default value "
2022
2016
"of 0 means to replace all occurrences."
2023
- msgstr "選擇性的參數 *count* 是最大替換次數 ;*count* "
2024
- "必須是一個非負整數。預設值為0,表示取代所有出現次數 。"
2017
+ msgstr "可選參數 *count* 為要取代的模式出現的最大次數 ;*count* 必須是非負整數。 "
2018
+ "預設值為 0,表示取代所有出現的次數 。"
2025
2019
2026
2020
#: ../../howto/regex.rst:1150
2027
- #, fuzzy
2028
2021
msgid ""
2029
2022
"Here's a simple example of using the :meth:`~re.Pattern.sub` method. It "
2030
2023
"replaces colour names with the word ``colour``::"
2031
- msgstr "以下是使用 ``sub`` 方法的一個簡單範例。它會將顏色名稱替換為「color」:"
2024
+ msgstr ""
2025
+ "以下是使用 :meth:`~re.Pattern.sub` "
2026
+ "方法的簡單範例。它將顏色名稱替換為單字「colour」:\n"
2027
+ "\n"
2028
+ "::"
2032
2029
2033
2030
#: ../../howto/regex.rst:1159
2034
- #, fuzzy
2035
2031
msgid ""
2036
2032
"The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-"
2037
2033
"tuple containing the new string value and the number of replacements that "
2038
2034
"were performed::"
2039
- msgstr ""
2040
- ":meth:`~re.Pattern.subn` 方法與 :meth:`~re.SubPattern.sub` "
2041
- "相同,但其回傳值為一個包含新字串和替換次數共兩個元素的二元組(tuple)。"
2035
+ msgstr ":meth:`~re.Pattern.subn` "
2036
+ "方法執行相同的工作,但回傳包含新的字串值和執行的取代數量的二元組(2-tuple):"
2042
2037
2043
2038
#: ../../howto/regex.rst:1168
2044
- #, fuzzy
2045
2039
msgid ""
2046
2040
"Empty matches are replaced only when they're not adjacent to a previous "
2047
2041
"empty match. ::"
2048
- msgstr "只有當一個空匹配不相鄰於先前的空匹配時,才會替換空匹配 。 ::"
2042
+ msgstr "只有當空字串匹配不與先前的空字串匹配相鄰時,才會進行取代 。 ::"
2049
2043
2050
2044
#: ../../howto/regex.rst:1175
2051
- #, fuzzy
2052
2045
msgid ""
2053
2046
"If *replacement* is a string, any backslash escapes in it are processed. "
2054
2047
"That is, ``\\ n`` is converted to a single newline character, ``\\ r`` is "
@@ -2058,21 +2051,23 @@ msgid ""
2058
2051
"incorporate portions of the original text in the resulting replacement "
2059
2052
"string."
2060
2053
msgstr ""
2061
- "如果 *replacement* 是一個字串,其中的反斜線會被處理。也就是 `\\ n"
2062
- "` 會轉換成新行符號,`\\ r` 會轉換成回車鍵等等。未知的轉義符如 `\\ &` "
2063
- "則不變留作原樣。可替代參照(backreferences),例如 `\\ 6`,將會被正則表達式中"
2064
- "相對應組別所匹配到的子字串取代掉,因此可以在替換字串中加上原始訊息文字部分"
2054
+ "如果 *replacement* 是一個字串,其中的反斜線跳脫符號會被處理。也就是說,``\\ n"
2055
+ "`` 會轉換成單一換行符號,``\\ r`` 會轉換成回車符號,以此類推。"
2056
+ "未知的跳脫符號如 ``\\ &`` 會保留原樣。反向引用(backreferences),例如 ``\\ 6``"
2057
+ ",會被替換為正則表達式中對應群組所匹配的子字串。這樣,你可以將原始文本中的部"
2058
+ "分內容納入所得到的替換字串中。"
2065
2059
2066
2060
#: ../../howto/regex.rst:1182
2067
- #, fuzzy
2068
2061
msgid ""
2069
2062
"This example matches the word ``section`` followed by a string enclosed in "
2070
2063
"``{``, ``}``, and changes ``section`` to ``subsection``::"
2071
- msgstr "本例尋找單字「section」後,接著一串以大括號包覆的字詞,並將「section」替換為"
2072
- "「subsection」。即:"
2064
+ msgstr ""
2065
+ "這個範例會匹配單字 ``section`` 後面接著一個被 ``{`` 和 ``}`` 包圍的字串,"
2066
+ "並將 ``section`` 替換為 ``subsection``:\n"
2067
+ "\n"
2068
+ "::"
2073
2069
2074
2070
#: ../../howto/regex.rst:1189
2075
- #, fuzzy
2076
2071
msgid ""
2077
2072
"There's also a syntax for referring to named groups as defined by the ``(?"
2078
2073
"P<name>...)`` syntax. ``\\ g<name>`` will use the substring matched by the "
@@ -2083,33 +2078,36 @@ msgid ""
2083
2078
"literal character ``'0'``.) The following substitutions are all equivalent, "
2084
2079
"but use all three variations of the replacement string. ::"
2085
2080
msgstr ""
2086
- "``(?P<name>...)`` 的語法可以用來引用以 ``name`` 為名的群組,``\\ g<name>`` "
2087
- "將會使用所對應到的子字串在命名群組中帶有這個名稱。 "
2088
- "一定也可以使用对应的群组编号来替换(即 \\ g<number>)。因此,\\ g<2> 相當于 \\ 2"
2089
- ",在替換字符串中沒什麼歧义。但是如果连接了其它字符时,则不然:例如“\\ g<2>0”"
2090
- "操作代表第二个分组加上一个0. 而没有被转义为包含两个数字的分组引用\" 20\" . "
2091
- "下面三种情况等价而且展示三种形式的替换字符串:."
2081
+ "在正則表達式中,也有一種引用使用 ``(?P<name>...)`` "
2082
+ "語法定義的命名群組的方式。``\\ g<name>`` 會使用由群組名稱 ``name`` "
2083
+ "所匹配的子字串,而 ``\\ g<number>`` 則使用對應的群組編號。因此,``\\ g<2>`` 與 "
2084
+ "``\\ 2`` 是等價的,但在替換字串中,使用 ``\\ g<2>0`` 這樣的寫法不會有歧義(``"
2085
+ "\\ 20`` 會被解釋為群組 20 的引用,而不是群組 2 後面跟著字元 "
2086
+ "``'0'``)。下面列舉了一些等價的替換字串,使用了這三種不同的寫法:\n"
2087
+ "\n"
2088
+ "::"
2092
2089
2093
2090
#: ../../howto/regex.rst:1206
2094
- #, fuzzy
2095
2091
msgid ""
2096
2092
"*replacement* can also be a function, which gives you even more control. If "
2097
2093
"*replacement* is a function, the function is called for every non-"
2098
2094
"overlapping occurrence of *pattern*. On each call, the function is passed "
2099
2095
"a :ref:`match object <match-objects>` argument for the match and can use "
2100
2096
"this information to compute the desired replacement string and return it."
2101
2097
msgstr ""
2102
- "*replacement* (替換物) 也可以是一個函數,這樣就能讓你得到更多的控制 。如果 "
2103
- "*replacement* 是一個函數,則在每次非重疊出現 *pattern* 的地方都會呼叫該函式。 "
2104
- " 在每次呼叫中,將傳遞給該函式 :ref:`match object <match-objects>` "
2105
- "參數以供與匹配相關的替換操作並將其返回 。"
2098
+ "*replacement* 也可以是一個函數,這樣你就可以更加靈活地控制替換的過程 。如果 "
2099
+ "*replacement* 是一個函數,那麼這個函數會在每次非重疊出現 *pattern* "
2100
+ "的地方被調用。每次調用時,函數會收到一個 :ref:`match object <match-objects>` "
2101
+ "作為參數,你可以使用這個對象的信息來計算所需的替換字串,並將其返回 。"
2106
2102
2107
2103
#: ../../howto/regex.rst:1212
2108
- #, fuzzy
2109
2104
msgid ""
2110
2105
"In the following example, the replacement function translates decimals into "
2111
2106
"hexadecimal::"
2112
- msgstr "以下是範例,此替換函數可將十進制轉譯成十六進制:"
2107
+ msgstr ""
2108
+ "以下是範例,此替換函數可將十進制轉譯成十六進制:\n"
2109
+ "\n"
2110
+ "::"
2113
2111
2114
2112
#: ../../howto/regex.rst:1224
2115
2113
#, fuzzy
@@ -2143,12 +2141,10 @@ msgstr ""
2143
2141
",而且偶爾會表現出你未曾預期的結果。本節將指出其中一些最常見的陷阱。"
2144
2142
2145
2143
#: ../../howto/regex.rst:1240
2146
- #, fuzzy
2147
2144
msgid "Use String Methods"
2148
2145
msgstr "使用字串方法"
2149
2146
2150
2147
#: ../../howto/regex.rst:1242
2151
- #, fuzzy
2152
2148
msgid ""
2153
2149
"Sometimes using the :mod:`re` module is a mistake. If you're matching a "
2154
2150
"fixed string, or a single character class, and you're not using any :mod:"
@@ -2160,13 +2156,13 @@ msgid ""
2160
2156
"engine."
2161
2157
msgstr ""
2162
2158
"有時候使用 :mod:`re` "
2163
- "模組會是一個錯誤。如果您只是匹配固定字串或單一字符類,並且不使用任何: "
2164
- "const:`~re.IGNORECASE` 等模块功能,则可能不需要完整的正規表達式的功能。"
2165
- "相對地, 字符串有好幾種方法來執行操作以查找固定字符串,而這些方法通常更快,因"
2166
- "為其實現是一個被優化、小型 C loop 而已,而非大型、更廣泛的正則引擎"
2159
+ "模組是一個錯誤。如果你只是匹配一個固定的字符串,或者一個單一的字符類,"
2160
+ "而且你沒有使用任何 :mod:`re` 的特性,比如 :const:`~re.IGNORECASE` "
2161
+ "標誌,那麼正則表達式的全部功能可能並不需要。對於固定字符串,Python "
2162
+ "字符串類型提供了一些方法可以執行相應操作,而且通常會更快,因為實現是一個小的 "
2163
+ "C 循環,被針對該用途進行了優化,而不是一個大而泛化的正則表達式引擎。"
2167
2164
2168
2165
#: ../../howto/regex.rst:1250
2169
- #, fuzzy
2170
2166
msgid ""
2171
2167
"One example might be replacing a single fixed string with another one; for "
2172
2168
"example, you might replace ``word`` with ``deed``. :func:`re.sub` seems "
@@ -2178,12 +2174,13 @@ msgid ""
2178
2174
"``word`` have a word boundary on either side. This takes the job beyond :"
2179
2175
"meth:`!replace`'s abilities.)"
2180
2176
msgstr ""
2181
- "一個例子可能是將一個固定字符串替換為另一個,例如您可以將“word” 替换为 "
2182
- "“deed”。使用 :func:`re.sub` 函数似乎是最佳選擇,但要考虑到 :meth:`~str."
2183
- "replace` 方法。请注意,:meth:`!replace` 也會替换單詞内的“word”,将“swordfish”"
2184
- "变成了\" sdeedfish\" ,但单纯RE \" word\" 也会这样做。 "
2185
- "(为了避免在单词的部分执行替换,模式必须是`\\ bword\\ b' ,以要求 `word`` "
2186
- "在任何一侧都有一个字边界。 这将超出 :meth:! replace 的能力范围)"
2177
+ "一個例子可能是用另一個固定的字符串替換一個字符串;例如,你可能會將 ``word`` "
2178
+ "替換為 ``deed``。:func:`re.sub` 看起來是用於此目的的函數,但是請考慮使用 "
2179
+ ":meth:`~str.replace` 方法。請注意,:meth:`!replace` 方法也會將 ``word`` "
2180
+ "替換為單詞中的 ``word``,將 ``swordfish`` 變成 ``sdeedfish``,"
2181
+ "但是單純的正則表達式 ``word`` 也會這樣做。(為了避免在單詞的一部分進行替換,"
2182
+ "模式必須是 ``\\ bword\\ b``,以要求 ``word`` 在兩側都有單詞邊界。"
2183
+ "這使得這個任務超出了 :meth:`!replace` 的能力範圍。)"
2187
2184
2188
2185
#: ../../howto/regex.rst:1259
2189
2186
#, fuzzy
@@ -2327,24 +2324,19 @@ msgstr ""
2327
2324
"對於這些任務使用 HTML 或XML 解析器模組)"
2328
2325
2329
2326
#: ../../howto/regex.rst:1346
2330
- #, fuzzy
2331
2327
msgid "Using re.VERBOSE"
2332
- msgstr ""
2333
- "使用 re.VERBOSE在使用 Python 的正規表示式來進行字串處理時,re 模組中的 "
2334
- "VERBOSE 設定是很好用的一個功能。它讓你可以將想要搜尋/替換的模式寫成一個更容易"
2335
- "閱讀且較為完整的格式,適合於需要撰寫複雜正則表達式的程式設計師使用。"
2328
+ msgstr "使用 re.VERBOSE"
2336
2329
2337
2330
#: ../../howto/regex.rst:1348
2338
- #, fuzzy
2339
2331
msgid ""
2340
2332
"By now you've probably noticed that regular expressions are a very compact "
2341
2333
"notation, but they're not terribly readable. REs of moderate complexity can "
2342
2334
"become lengthy collections of backslashes, parentheses, and metacharacters, "
2343
2335
"making them difficult to read and understand."
2344
2336
msgstr ""
2345
- "現在你可能已經注意到正規表示式(regular expression)是一種非常緊湊的符號,但 "
2346
- "並不容易閱讀。中等複雜度的正規表達式可能會變成裝滿斜線、括號和元字符的長字符 "
2347
- "串,使其很難理解和閱讀 。"
2337
+ "到現在為止,你可能已經發現正則表達式是一種非常緊湊的表示方法,但是它們並不是 "
2338
+ "非常易讀的。中等複雜度的正則表達式可能會變成一長串的反斜線、括號和元字符,使 "
2339
+ "它們難以閱讀和理解 。"
2348
2340
2349
2341
#: ../../howto/regex.rst:1353
2350
2342
msgid ""
0 commit comments