Skip to content

Conversation

@Robin-zero
Copy link
Contributor

@Robin-zero Robin-zero commented Jul 19, 2018

翻译章节

《算法和数据结构——正则表达式》

变更文件

  • regular-expressions.json

  • regular-expressions.md

翻译进度

  • 50%

  • 0%

@S1ngS1ng S1ngS1ng added the ready for review Use when a translation (?) PR is ready for review label Jul 21, 2018
Copy link
Contributor

@S1ngS1ng S1ngS1ng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于 matchsearchfind,你给出了多种翻译。其实应该统一一下的。

还有 testtest 是 RegExp 的方法,因此发起者应为一个正则表达式。而 searchmatch 均为字符串的方法,发起者应为字符串。

还有 find,和 look for。这里的语序你翻译的没错:
image

find 不是字符串或 RegExp 的方法,直接翻译成 匹配到找到 应该就够了。
match 也是一样,翻译成 匹配到 就好。
search 你翻译的是 搜索,我感觉可以;但有时可能换成 搜寻 通顺些。比如:

image

后两个用搜寻,个人感觉好些。注意语序。

test是用来验证是否通过 pattern 里定义的规则的测试,所以翻译成 检测 会不会好些?

类似的评论我就不再在 diff 里 comment 了。你更新之后仔细检查一下前后文吧


建议 pattern 翻译为 规则匹配规则 就好。不要翻译成 模式


全篇你的 =>


我现在 review 到了 161 行。因为改动比较多,请先修改,然后检查一下标点和空格,以及通篇翻译是否通顺

"Regular expressions are used in programming languages to match parts of strings. You create patterns to help you do that matching.",
"If you want to find the word <code>\"the\"</code> in the string <code>\"The dog chased the cat\"</code>, you could use the following regular expression: <code>/the/</code>. Notice that quote marks are not required within the regular expression.",
"JavaScript has multiple ways to use regexes. One way to test a regex is using the <code>.test()</code> method. The <code>.test()</code> method takes the regex, applies it to a string (which is placed inside the parentheses), and returns <code>true</code> or <code>false</code> if your pattern finds something or not.",
"在编程语言中,正则表达式用于匹配指定的字符串。通过正则表达式创建模式(规则)可以帮你完成指定匹配。",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

模式 建议 =>
匹配模式


你可以通过创建匹配模式(规则)来匹配字符串中指定的部分。

"JavaScript has multiple ways to use regexes. One way to test a regex is using the <code>.test()</code> method. The <code>.test()</code> method takes the regex, applies it to a string (which is placed inside the parentheses), and returns <code>true</code> or <code>false</code> if your pattern finds something or not.",
"在编程语言中,正则表达式用于匹配指定的字符串。通过正则表达式创建模式(规则)可以帮你完成指定匹配。",
"如果你想要在字符串 <code>\"The dog chased the cat\"</code> 中匹配到 <code>\"the\"</code> 这个单词,你可以使用如下正则表达式:<code>/the/</code>。注意,正则表达式中不需要引号。",
"JavaScript中有多种使用正则表达式的方法。测试正则表达式的一种方法是使用 <code>.test()</code> 方法。<code>.test()</code> 方法会把你编写的正则表达式应用到一个字符串(即括号内的内容),如果你的模式成功匹配到字符,则返回 <code>true</code>,反之,返回 <code>false</code>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaScript 之后应该加上空格


你的模式 建议 =>
你定义的规则

"<blockquote>let testStr = \"freeCodeCamp\";<br>let testRegex = /Code/;<br>testRegex.test(testStr);<br>// Returns true</blockquote>",
"<hr>",
"Apply the regex <code>myRegex</code> on the string <code>myString</code> using the <code>.test()</code> method."
"使用 <code>.test()</code> 方法把正则表达式 <code>myRegex</code> 应用到字符串 <code>myString</code> 上面。"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 <code>.test()</code> 方法把正则表达式 <code>myRegex</code> 应用到字符串 <code>myString</code> 上面。 建议 =>
使用 <code>.test()</code> 方法,测试字符串 <code>myString</code> 是否符合正则表达式 <code>myRegex</code> 定义的规则。

这样会不会通顺些?你决定吧

"text": "Your result should return <code>true</code>.",
"testString": "assert(result === true, 'Your result should return <code>true</code>.');"
"text": "你的返回结果应该为 <code>true</code>.",
"testString": "assert(result === true, '你的返回结果应该为 <code>true</code>.');"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两行,结尾应该是全角句号。

"在上一个挑战中,你使用正则表达式 <code>/Hello/</code> 搜索到了字符串 <code>\"Hello\"</code>。那个字符串搜索字符串 <code>\"Hello\"</code> 的文字匹配。下面是另一个搜索字符串 <code>\"Kevin\"</code> 文字匹配的示例:",
"<blockquote>let testStr = \"Hello, my name is Kevin.\";<br>let testRegex = /Kevin/;<br>testRegex.test(testStr);<br>// Returns true</blockquote>",
"Any other forms of <code>\"Kevin\"</code> will not match. For example, the regex <code>/Kevin/</code> will not match <code>\"kevin\"</code> or <code>\"KEVIN\"</code>.",
"任何其他形式的 <code>\"Kevin\"</code> 都不会被匹配。例如,正则表达式 <code>/Kevin/</code> 不会匹配 <code>\"kevin\"</code> 或者 <code>\"KEVIN\"</code>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结尾句号之前多了个空格。

"你还可以搜索不止两个模式。你可以通过添加更多的模式来实现这一功能,这些模式将包含更多的 <code>OR</code> 操作符来分隔它们,比如 <code>/yes|no|maybe/</code>",
"<hr>",
"Complete the regex <code>petRegex</code> to match the pets <code>\"dog\"</code>, <code>\"cat\"</code>, <code>\"bird\"</code>, or <code>\"fish\"</code>."
"完成正则表达式 <code>petRegex</code> 匹配 <code>\"dog\"</code><code>\"cat\"</code><code>\"bird\"</code> 或者 <code>\"fish\"</code>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

完成正则表达式 <code>petRegex</code> 匹配…… => 完成正则表达式 <code>petRegex</code>,让它可以匹配到……

{
"text": "Your regex <code>petRegex</code> should return <code>true</code> for the string <code>\"John has a pet dog.\"</code>",
"testString": "assert(petRegex.test('John has a pet dog.'), 'Your regex <code>petRegex</code> should return <code>true</code> for the string <code>\"John has a pet dog.\"</code>');"
"text": "对于字符串 <code>\"John has a pet dog.\"</code>,你的正则表达式 <code>petRegex</code> 应该返回 <code>true</code>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的表述都不太好。返回 true 的不是 petRegex,而应该是 petRegex.test()

因此,要么说:
对于字符串 <code>\"John has a pet dog.\"</code>,你的正则表达式 <code>petRegex</code> 的 <code>test</code> 方法应该返回 <code>true</code> 。
或者说:字符串 <code>\"John has a pet dog.\"</code> 应该可以通过正则表达式 <code>petRegex</code> 的测试。

下同。选一个一起改吧,或者如果你有更好的表达方式也可以

"Up until now, you've looked at regexes to do literal matches of strings. But sometimes, you might want to also match case differences.",
"Case (or sometimes letter case) is the difference between uppercase letters and lowercase letters. Examples of uppercase are <code>\"A\"</code>, <code>\"B\"</code>, and <code>\"C\"</code>. Examples of lowercase are <code>\"a\"</code>, <code>\"b\"</code>, and <code>\"c\"</code>.",
"You can match both cases using what is called a flag. There are other flags but here you'll focus on the flag that ignores case - the <code>i</code> flag. You can use it by appending it to the regex. An example of using this flag is <code>/ignorecase/i</code>. This regex can match the strings <code>\"ignorecase\"</code>, <code>\"igNoreCase\"</code>, and <code>\"IgnoreCase\"</code>.",
"到目前为止,你已经查看了利用正则表达式来执行字符串的文字匹配。但是有时候,你可能也想匹配不同的情况。",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 case 不是情况,是英文字母大小写

"Case (or sometimes letter case) is the difference between uppercase letters and lowercase letters. Examples of uppercase are <code>\"A\"</code>, <code>\"B\"</code>, and <code>\"C\"</code>. Examples of lowercase are <code>\"a\"</code>, <code>\"b\"</code>, and <code>\"c\"</code>.",
"You can match both cases using what is called a flag. There are other flags but here you'll focus on the flag that ignores case - the <code>i</code> flag. You can use it by appending it to the regex. An example of using this flag is <code>/ignorecase/i</code>. This regex can match the strings <code>\"ignorecase\"</code>, <code>\"igNoreCase\"</code>, and <code>\"IgnoreCase\"</code>.",
"到目前为止,你已经查看了利用正则表达式来执行字符串的文字匹配。但是有时候,你可能也想匹配不同的情况。",
"大小写(或者字母大小写)是大写字母和小写字母的区别。大写字母的例子有 <code>\"A\"</code><code>\"B\"</code> <code>\"C\"</code>。小写字母的例子有 <code>\"a\"</code><code>\"b\"</code> <code>\"c\"</code>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删掉全角标点前,半角字符后的空格。

这样是对的:
image

这样就是错的:
image

"You can match both cases using what is called a flag. There are other flags but here you'll focus on the flag that ignores case - the <code>i</code> flag. You can use it by appending it to the regex. An example of using this flag is <code>/ignorecase/i</code>. This regex can match the strings <code>\"ignorecase\"</code>, <code>\"igNoreCase\"</code>, and <code>\"IgnoreCase\"</code>.",
"到目前为止,你已经查看了利用正则表达式来执行字符串的文字匹配。但是有时候,你可能也想匹配不同的情况。",
"大小写(或者字母大小写)是大写字母和小写字母的区别。大写字母的例子有 <code>\"A\"</code><code>\"B\"</code> <code>\"C\"</code>。小写字母的例子有 <code>\"a\"</code><code>\"b\"</code> <code>\"c\"</code>",
"你可以使用所谓的模式修正符来匹配这两种情况。有许多其他标志,不过这里主要关注忽略大小写的模式修正符 - <code>i</code> 模式修正符。你可以通过将它附加到正则表达式之后来使用它。这里给出使用该模式修正符的一个实例 <code>/ignorecase/i</code>。这个字符串可以匹配字符串 <code>\"ignorecase\"</code><code>\"igNoreCase\"</code> <code>\"IgnoreCase\"</code>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@S1ngS1ng S1ngS1ng added the need update Use when a translation (?) PR has been reviewed and needs to address comments label Jul 22, 2018
@huluoyang huluoyang removed the ready for review Use when a translation (?) PR is ready for review label Jul 24, 2018
@huluoyang huluoyang changed the title Translation of document "regular-expressions", 20% completed! Translate regular-expressions Jul 24, 2018
@S1ngS1ng
Copy link
Contributor

S1ngS1ng commented Jul 29, 2018

@Robin-zero 看下 comments,记得更新,以及<code>的空格需要调整

@S1ngS1ng
Copy link
Contributor

Changes addressed in #21

@S1ngS1ng S1ngS1ng closed this Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need update Use when a translation (?) PR has been reviewed and needs to address comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants