@@ -732,7 +732,7 @@ msgstr "方法 / 属性"
732
732
#: ../../howto/regex.rst:363 ../../howto/regex.rst:417
733
733
#: ../../howto/regex.rst:1065
734
734
msgid "Purpose"
735
- msgstr "目的 "
735
+ msgstr "用途 "
736
736
737
737
#: ../../howto/regex.rst:365
738
738
msgid "``match()``"
@@ -811,16 +811,17 @@ msgid ""
811
811
"<match-objects>`, so you should store the result in a variable for later "
812
812
"use. ::"
813
813
msgstr ""
814
- "现在,让我们尝试一下它应该匹配的字符串,例如 ``tempo``。在这个例子中 :meth:`~re.Pattern.match` 将返回一个 "
815
- ":ref:`匹配对象 <match-objects>`,因此你应该将结果储存到一个变量中以供稍后使用 。 ::"
814
+ "接下来,让我们尝试把这个正则应用到一个可以匹配的字符串,比如 ``tempo``。在这个例子中 , :meth:`~re.Pattern.match` "
815
+ "会返回一个 :ref:`匹配对象 <match-objects>`,所以你应该将结果储存到一个变量中,以便后续使用 。 ::"
816
816
817
817
#: ../../howto/regex.rst:412
818
818
msgid ""
819
819
"Now you can query the :ref:`match object <match-objects>` for information "
820
820
"about the matching string. Match object instances also have several methods"
821
821
" and attributes; the most important ones are:"
822
822
msgstr ""
823
- "现在你可以检查 :ref:`匹配对象 <match-objects>` 以获取有关匹配字符串的信息。 匹配对象实例也有几个方法和属性;最重要的是:"
823
+ "现在你可以查询 :ref:`匹配对象 <match-objects>` 来获取有关匹配字符串的信息。 "
824
+ "匹配对象实例也有多个方法和属性,其中比较最重要的是:"
824
825
825
826
#: ../../howto/regex.rst:419
826
827
msgid "``group()``"
@@ -852,11 +853,11 @@ msgstr "``span()``"
852
853
853
854
#: ../../howto/regex.rst:425
854
855
msgid "Return a tuple containing the (start, end) positions of the match"
855
- msgstr "返回包含匹配 (start, end ) 位置的元组"
856
+ msgstr "返回包含匹配 (起始, 结束 ) 位置的元组"
856
857
857
858
#: ../../howto/regex.rst:429
858
859
msgid "Trying these methods will soon clarify their meaning::"
859
- msgstr "尝试这些方法很快就会清楚它们的含义 ::"
860
+ msgstr "测下一下这些方法,很快就能明白它们的含义 ::"
860
861
861
862
#: ../../howto/regex.rst:438
862
863
msgid ""
@@ -869,25 +870,28 @@ msgid ""
869
870
"scans through the string, so the match may not start at zero in that case. "
870
871
"::"
871
872
msgstr ""
872
- ":meth:`~re.Match.group` 返回正则匹配的子字符串。 :meth:`~re.Match.start` 和 "
873
- ":meth:`~re.Match.end` 返回匹配的起始和结束索引。 :meth:`~re.Match.span` 在单个元组中返回开始和结束索引。 "
874
- "由于 :meth:`~re.Pattern.match` 方法只检查正则是否在字符串的开头匹配,所以 :meth:`!start` 将始终为零。 "
875
- "但是,模式的 :meth:`~re.Pattern.search` 方法会扫描字符串,因此在这种情况下匹配可能不会从零开始。::"
873
+ ":meth:`~re.Match.group` 方法返回正则表达式匹配到的子字符串。 :meth:`~re.Match.start` 和 "
874
+ ":meth:`~re.Match.end` 方法分别返回匹配的起始和结束索引。 :meth:`~re.Match.span` "
875
+ "方法则以元组的形式返回始始和结束索引。 由于 :meth:`~re.Pattern.match` 方法只检查正则表达式能否在字符串的开头匹配,所以 "
876
+ ":meth:`!start` 方法始终返回零。 而 :meth:`~re.Pattern.search` "
877
+ "方法会扫描字符串的所有位置,因此匹配的起始索引不一定是零。::"
876
878
877
879
#: ../../howto/regex.rst:455
878
880
msgid ""
879
881
"In actual programs, the most common style is to store the :ref:`match object"
880
882
" <match-objects>` in a variable, and then check if it was ``None``. This "
881
883
"usually looks like::"
882
884
msgstr ""
883
- "在实际程序中,最常见的样式是在变量中存储 :ref:`匹配对象 <match-objects>`,然后检查它是否为 ``None``。 "
884
- "这通常看起来像 ::"
885
+ "在实际编程中,最常用的方式是将 :ref:`匹配对象 <match-objects>` 储存到一个变量中,然后检查这个变量是否为 ``None``。 "
886
+ "这种做法通常如下所示 ::"
885
887
886
888
#: ../../howto/regex.rst:466
887
889
msgid ""
888
890
"Two pattern methods return all of the matches for a pattern. "
889
891
":meth:`~re.Pattern.findall` returns a list of matching strings::"
890
- msgstr "两种模式方法返回模式的所有匹配项。 :meth:`~re.Pattern.findall` 返回匹配字符串的列表::"
892
+ msgstr ""
893
+ "有两个 pattern 方法可以用来返回 pattern 的所有匹配项。 :meth:`~re.Pattern.findall` "
894
+ "方法会返回一个包含所有匹配字符串的列表::"
891
895
892
896
#: ../../howto/regex.rst:473
893
897
msgid ""
0 commit comments