Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e9fcdd

Browse files
josixweblate
authored andcommitted
Translated using Weblate (regex (generated) (regex))
Currently translated at 93.0% (266 of 286 strings) Translation: python-doc-zhtw/howto Translate-URL: http://weblate.andyjjrt.cc/projects/python-doc-zhtw/howto/regex/
1 parent 4098f43 commit 6e9fcdd

File tree

1 file changed

+75
-83
lines changed

1 file changed

+75
-83
lines changed

howto/regex.po

Lines changed: 75 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ msgstr ""
1111
"Report-Msgid-Bugs-To: \n"
1212
"POT-Creation-Date: 2022-10-15 20:43+0000\n"
1313
"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"
1515
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-tw)"
1616
"\n"
1717
"Language: regex\n"
@@ -975,8 +975,8 @@ msgstr ""
975975
"你不必創建一個模式對象並調用其方法;相應的 :mod:`re` "
976976
"模塊還提供了頂級函數,如::func:`~re.match`, :func:`~re.search`, :func:`~re."
977977
"findall`, :func:`~re.sub`。這些函數與相應的模式方法具有相同的引數(以 RE "
978-
"字串作為第一個引數),仍然返回 ``None`` 或者是匹配對象 (:ref:`match-objects`)"
979-
" 實例。 ::"
978+
"字串作為第一個引數),仍然返回 ``None`` 或者是匹配物件(match object)( :ref"
979+
":`match-objects` ) 實例。 ::"
980980

981981
#: ../../howto/regex.rst:510
982982
msgid ""
@@ -1916,19 +1916,16 @@ msgid "``subn()``"
19161916
msgstr "``subn()``"
19171917

19181918
#: ../../howto/regex.rst:1072
1919-
#, fuzzy
19201919
msgid ""
19211920
"Does the same thing as :meth:`!sub`, but returns the new string and the "
19221921
"number of replacements"
1923-
msgstr "跟 `sub()` 方法一樣,但回傳值是所產生的新字串以及替換發生的次數"
1922+
msgstr "跟 `!sub()` 方法一樣,但回傳值是所產生的新字串以及替換發生的次數"
19241923

19251924
#: ../../howto/regex.rst:1079
1926-
#, fuzzy
19271925
msgid "Splitting Strings"
19281926
msgstr "分割字串"
19291927

19301928
#: ../../howto/regex.rst:1081
1931-
#, fuzzy
19321929
msgid ""
19331930
"The :meth:`~re.Pattern.split` method of a pattern splits a string apart "
19341931
"wherever the RE matches, returning a list of the pieces. It's similar to "
@@ -1937,24 +1934,24 @@ msgid ""
19371934
"splitting by whitespace or by a fixed string. As you'd expect, there's a "
19381935
"module-level :func:`re.split` function, too."
19391936
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`。"
19441942

19451943
#: ../../howto/regex.rst:1092
1946-
#, fuzzy
19471944
msgid ""
19481945
"Split *string* by the matches of the regular expression. If capturing "
19491946
"parentheses are used in the RE, then their contents will also be returned as "
19501947
"part of the resulting list. If *maxsplit* is nonzero, at most *maxsplit* "
19511948
"splits are performed."
19521949
msgstr ""
1953-
"拆分*string*,以正則表達式作匹配。若RE使用捕獲括號,將其內容也一同返回為結果"
1954-
"列表的元素。當*maxsplit*非零時,最多執行 *maxsplit* 次拆分。"
1950+
"以正則表達式匹配結果拆分 *string* 。若 RE 使用捕獲括號(capturing "
1951+
"parentheses),將其內容也一同返回為結果列表的元素。當 *maxsplit* 非零時,"
1952+
"最多執行 *maxsplit* 次拆分。"
19551953

19561954
#: ../../howto/regex.rst:1097
1957-
#, fuzzy
19581955
msgid ""
19591956
"You can limit the number of splits made, by passing a value for *maxsplit*. "
19601957
"When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the "
@@ -1964,35 +1961,35 @@ msgid ""
19641961
msgstr ""
19651962
"你可以透過設定 *maxsplit* 參數來限制分割次數,當 *maxsplit* 值不是零時,最多"
19661963
"分割此數量並將字串剩餘部份作為清單的最終元素回傳。在下面的範例中,以非英文字"
1967-
"母和數字為區隔符號。 ::"
1964+
"母和數字為區隔符號。:\n"
1965+
"\n"
1966+
"::"
19681967

19691968
#: ../../howto/regex.rst:1109
1970-
#, fuzzy
19711969
msgid ""
19721970
"Sometimes you're not only interested in what the text between delimiters is, "
19731971
"but also need to know what the delimiter was. If capturing parentheses are "
19741972
"used in the RE, then their values are also returned as part of the list. "
19751973
"Compare the following calls::"
19761974
msgstr ""
19771975
"有時你不僅對分隔符之間的文本有興趣,也需要知道該分隔符是什麼。 "
1978-
"如果在正規表示式(RE)中使用捕獲括號,那麼它們的值也作為列表的一部分返回。 "
1979-
"比較以下調用:"
1976+
"如果在正規表示式(RE)中使用捕獲括號(capturing "
1977+
"parentheses),那麼它們的值也作為列表的一部分返回。 比較以下調用:\n"
1978+
"\n"
1979+
"::"
19801980

19811981
#: ../../howto/regex.rst:1121
1982-
#, fuzzy
19831982
msgid ""
19841983
"The module-level function :func:`re.split` adds the RE to be used as the "
19851984
"first argument, but is otherwise the same. ::"
1986-
msgstr "模組層級函式 :func:`re.split` 新增一個參數,作為被用來作為第一個引數的正規表"
1987-
"示式,但除此之外功能和原本相同。"
1985+
msgstr "模塊級別的函數 :func:re.split "
1986+
"將要使用的正則表達式作為第一個參數添加,但其他方面與上述方法相同。::"
19881987

19891988
#: ../../howto/regex.rst:1133
1990-
#, fuzzy
19911989
msgid "Search and Replace"
19921990
msgstr "搜尋和取代"
19931991

19941992
#: ../../howto/regex.rst:1135
1995-
#, fuzzy
19961993
msgid ""
19971994
"Another common task is to find all the matches for a pattern, and replace "
19981995
"them with a different string. The :meth:`~re.Pattern.sub` method takes a "
@@ -2004,51 +2001,47 @@ msgstr ""
20042001
"方法需要傳入替換值,可以是字串或函式,以及要處理的字串。"
20052002

20062003
#: ../../howto/regex.rst:1142
2007-
#, fuzzy
20082004
msgid ""
20092005
"Returns the string obtained by replacing the leftmost non-overlapping "
20102006
"occurrences of the RE in *string* by the replacement *replacement*. If the "
20112007
"pattern isn't found, *string* is returned unchanged."
20122008
msgstr ""
2013-
"回傳字串,此字串經取代來源字串 *string* "
2014-
"中最左邊且沒重複的區段符合所提供的正規表示式 RE 所產生之符合 REPLACEMENT "
2015-
"的內容。若未找到該模式,則回傳原始 *string* 字串。"
2009+
"回傳將 *string* 中最左邊的非重疊出現的正規表示式(RE)取代為 *replacement* "
2010+
"所得到的字串。如果找不到符合的模式,則回傳未更改的 *string*。"
20162011

20172012
#: ../../howto/regex.rst:1146
2018-
#, fuzzy
20192013
msgid ""
20202014
"The optional argument *count* is the maximum number of pattern occurrences "
20212015
"to be replaced; *count* must be a non-negative integer. The default value "
20222016
"of 0 means to replace all occurrences."
2023-
msgstr "選擇性的參數 *count* 是最大替換次數;*count* "
2024-
"必須是一個非負整數。預設值為0,表示取代所有出現次數。"
2017+
msgstr "可選參數 *count* 為要取代的模式出現的最大次數;*count* 必須是非負整數。"
2018+
"預設值為 0,表示取代所有出現的次數。"
20252019

20262020
#: ../../howto/regex.rst:1150
2027-
#, fuzzy
20282021
msgid ""
20292022
"Here's a simple example of using the :meth:`~re.Pattern.sub` method. It "
20302023
"replaces colour names with the word ``colour``::"
2031-
msgstr "以下是使用 ``sub`` 方法的一個簡單範例。它會將顏色名稱替換為「color」:"
2024+
msgstr ""
2025+
"以下是使用 :meth:`~re.Pattern.sub` "
2026+
"方法的簡單範例。它將顏色名稱替換為單字「colour」:\n"
2027+
"\n"
2028+
"::"
20322029

20332030
#: ../../howto/regex.rst:1159
2034-
#, fuzzy
20352031
msgid ""
20362032
"The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-"
20372033
"tuple containing the new string value and the number of replacements that "
20382034
"were performed::"
2039-
msgstr ""
2040-
":meth:`~re.Pattern.subn` 方法與 :meth:`~re.SubPattern.sub` "
2041-
"相同,但其回傳值為一個包含新字串和替換次數共兩個元素的二元組(tuple)。"
2035+
msgstr ":meth:`~re.Pattern.subn` "
2036+
"方法執行相同的工作,但回傳包含新的字串值和執行的取代數量的二元組(2-tuple):"
20422037

20432038
#: ../../howto/regex.rst:1168
2044-
#, fuzzy
20452039
msgid ""
20462040
"Empty matches are replaced only when they're not adjacent to a previous "
20472041
"empty match. ::"
2048-
msgstr "只有當一個空匹配不相鄰於先前的空匹配時,才會替換空匹配。 ::"
2042+
msgstr "只有當空字串匹配不與先前的空字串匹配相鄰時,才會進行取代。 ::"
20492043

20502044
#: ../../howto/regex.rst:1175
2051-
#, fuzzy
20522045
msgid ""
20532046
"If *replacement* is a string, any backslash escapes in it are processed. "
20542047
"That is, ``\\n`` is converted to a single newline character, ``\\r`` is "
@@ -2058,21 +2051,23 @@ msgid ""
20582051
"incorporate portions of the original text in the resulting replacement "
20592052
"string."
20602053
msgstr ""
2061-
"如果 *replacement* 是一個字串,其中的反斜線會被處理。也就是 `\\n"
2062-
"` 會轉換成新行符號,`\\r` 會轉換成回車鍵等等。未知的轉義符如 `\\&` "
2063-
"則不變留作原樣。可替代參照(backreferences),例如 `\\6`,將會被正則表達式中"
2064-
"相對應組別所匹配到的子字串取代掉,因此可以在替換字串中加上原始訊息文字部分"
2054+
"如果 *replacement* 是一個字串,其中的反斜線跳脫符號會被處理。也就是說,``\\n"
2055+
"`` 會轉換成單一換行符號,``\\r`` 會轉換成回車符號,以此類推。"
2056+
"未知的跳脫符號如 ``\\&`` 會保留原樣。反向引用(backreferences),例如 ``\\6``"
2057+
",會被替換為正則表達式中對應群組所匹配的子字串。這樣,你可以將原始文本中的部"
2058+
"分內容納入所得到的替換字串中。"
20652059

20662060
#: ../../howto/regex.rst:1182
2067-
#, fuzzy
20682061
msgid ""
20692062
"This example matches the word ``section`` followed by a string enclosed in "
20702063
"``{``, ``}``, and changes ``section`` to ``subsection``::"
2071-
msgstr "本例尋找單字「section」後,接著一串以大括號包覆的字詞,並將「section」替換為"
2072-
"「subsection」。即:"
2064+
msgstr ""
2065+
"這個範例會匹配單字 ``section`` 後面接著一個被 ``{`` 和 ``}`` 包圍的字串,"
2066+
"並將 ``section`` 替換為 ``subsection``:\n"
2067+
"\n"
2068+
"::"
20732069

20742070
#: ../../howto/regex.rst:1189
2075-
#, fuzzy
20762071
msgid ""
20772072
"There's also a syntax for referring to named groups as defined by the ``(?"
20782073
"P<name>...)`` syntax. ``\\g<name>`` will use the substring matched by the "
@@ -2083,33 +2078,36 @@ msgid ""
20832078
"literal character ``'0'``.) The following substitutions are all equivalent, "
20842079
"but use all three variations of the replacement string. ::"
20852080
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+
"::"
20922089

20932090
#: ../../howto/regex.rst:1206
2094-
#, fuzzy
20952091
msgid ""
20962092
"*replacement* can also be a function, which gives you even more control. If "
20972093
"*replacement* is a function, the function is called for every non-"
20982094
"overlapping occurrence of *pattern*. On each call, the function is passed "
20992095
"a :ref:`match object <match-objects>` argument for the match and can use "
21002096
"this information to compute the desired replacement string and return it."
21012097
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+
"作為參數,你可以使用這個對象的信息來計算所需的替換字串,並將其返回。"
21062102

21072103
#: ../../howto/regex.rst:1212
2108-
#, fuzzy
21092104
msgid ""
21102105
"In the following example, the replacement function translates decimals into "
21112106
"hexadecimal::"
2112-
msgstr "以下是範例,此替換函數可將十進制轉譯成十六進制:"
2107+
msgstr ""
2108+
"以下是範例,此替換函數可將十進制轉譯成十六進制:\n"
2109+
"\n"
2110+
"::"
21132111

21142112
#: ../../howto/regex.rst:1224
21152113
#, fuzzy
@@ -2143,12 +2141,10 @@ msgstr ""
21432141
",而且偶爾會表現出你未曾預期的結果。本節將指出其中一些最常見的陷阱。"
21442142

21452143
#: ../../howto/regex.rst:1240
2146-
#, fuzzy
21472144
msgid "Use String Methods"
21482145
msgstr "使用字串方法"
21492146

21502147
#: ../../howto/regex.rst:1242
2151-
#, fuzzy
21522148
msgid ""
21532149
"Sometimes using the :mod:`re` module is a mistake. If you're matching a "
21542150
"fixed string, or a single character class, and you're not using any :mod:"
@@ -2160,13 +2156,13 @@ msgid ""
21602156
"engine."
21612157
msgstr ""
21622158
"有時候使用 :mod:`re` "
2163-
"模組會是一個錯誤。如果您只是匹配固定字串或單一字符類,並且不使用任何: "
2164-
"const:`~re.IGNORECASE` 等模块功能,则可能不需要完整的正規表達式的功能。"
2165-
"相對地, 字符串有好幾種方法來執行操作以查找固定字符串,而這些方法通常更快,因"
2166-
"為其實現是一個被優化、小型 C loop 而已,而非大型、更廣泛的正則引擎"
2159+
"模組是一個錯誤。如果你只是匹配一個固定的字符串,或者一個單一的字符類,"
2160+
"而且你沒有使用任何 :mod:`re` 的特性,比如 :const:`~re.IGNORECASE` "
2161+
"標誌,那麼正則表達式的全部功能可能並不需要。對於固定字符串,Python "
2162+
"字符串類型提供了一些方法可以執行相應操作,而且通常會更快,因為實現是一個小的 "
2163+
"C 循環,被針對該用途進行了優化,而不是一個大而泛化的正則表達式引擎。"
21672164

21682165
#: ../../howto/regex.rst:1250
2169-
#, fuzzy
21702166
msgid ""
21712167
"One example might be replacing a single fixed string with another one; for "
21722168
"example, you might replace ``word`` with ``deed``. :func:`re.sub` seems "
@@ -2178,12 +2174,13 @@ msgid ""
21782174
"``word`` have a word boundary on either side. This takes the job beyond :"
21792175
"meth:`!replace`'s abilities.)"
21802176
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` 的能力範圍。)"
21872184

21882185
#: ../../howto/regex.rst:1259
21892186
#, fuzzy
@@ -2327,24 +2324,19 @@ msgstr ""
23272324
"對於這些任務使用 HTML 或XML 解析器模組)"
23282325

23292326
#: ../../howto/regex.rst:1346
2330-
#, fuzzy
23312327
msgid "Using re.VERBOSE"
2332-
msgstr ""
2333-
"使用 re.VERBOSE在使用 Python 的正規表示式來進行字串處理時,re 模組中的 "
2334-
"VERBOSE 設定是很好用的一個功能。它讓你可以將想要搜尋/替換的模式寫成一個更容易"
2335-
"閱讀且較為完整的格式,適合於需要撰寫複雜正則表達式的程式設計師使用。"
2328+
msgstr "使用 re.VERBOSE"
23362329

23372330
#: ../../howto/regex.rst:1348
2338-
#, fuzzy
23392331
msgid ""
23402332
"By now you've probably noticed that regular expressions are a very compact "
23412333
"notation, but they're not terribly readable. REs of moderate complexity can "
23422334
"become lengthy collections of backslashes, parentheses, and metacharacters, "
23432335
"making them difficult to read and understand."
23442336
msgstr ""
2345-
"現在你可能已經注意到正規表示式(regular expression)是一種非常緊湊的符號,但"
2346-
"並不容易閱讀。中等複雜度的正規表達式可能會變成裝滿斜線、括號和元字符的長字符"
2347-
"串,使其很難理解和閱讀。"
2337+
"到現在為止,你可能已經發現正則表達式是一種非常緊湊的表示方法,但是它們並不是"
2338+
"非常易讀的。中等複雜度的正則表達式可能會變成一長串的反斜線、括號和元字符,使"
2339+
"它們難以閱讀和理解。"
23482340

23492341
#: ../../howto/regex.rst:1353
23502342
msgid ""

0 commit comments

Comments
 (0)