5-regular-expressions/01-regexp-introduction/article.md and 02-regexp-methods/article.md#225
Merged
leviding merged 7 commits intojavascript-tutorial:zh-hansfrom Sep 17, 2018
Conversation
|
校对认领 |
Member
|
@BriFuture 欢迎欢迎,近期本 JavaScript 教程校对有奖励积分 |
BriFuture
reviewed
Sep 14, 2018
BriFuture
left a comment
There was a problem hiding this comment.
总的来说翻译的很好,但我觉得有一些小问题,你看看我改的是否合适。另外就是有两处中英文中间没有加上空格。
| 另一方面,`new RegExp` 允许从字符串中动态地构造模式。 | ||
|
|
||
| So we can figure out what we need to search and create `new RegExp` from it: | ||
| 所以我们可以找出需要搜索的字段,然后从这里创建 `new RegExp`: |
There was a problem hiding this comment.
然后从这里创建 new RegExp => 然后根据搜索字段创建 new RegExp
我觉得这个位置的 it 指代的是前面的 what to search
| 正则表达式是搜索和替换字符串的一种强大方式。 | ||
|
|
||
| In JavaScript regular expressions are implemented using objects of a built-in `RegExp` class and integrated with strings. | ||
| 在JavaScript中,正则表达式使用内置的“RegExp”类的对象实现,并与字符串集成。 |
There was a problem hiding this comment.
正则表达式使用内置的“RegExp”类的对象实现
这里的 using 感觉翻译成 “通过” 会不会更好点
|
|
||
| `m` | ||
| : Multiline mode (covered in the chapter <info:regexp-multiline>). | ||
| : 多行模式(详见 章节 <info:regexp-multiline>) |
| 1. The first search returns `-1` (not found), because the search is case-sensitive by default. | ||
| 2. With the flag `pattern:/LOVE/i` the search found `match:love` at position 2. | ||
| 1. 第一个搜索返回的是 `-1`(也就是没找到),因为搜索默认是区分大小写的。 | ||
| 2. 使用修饰符 `pattern:/LOVE/i`,搜索结果是索引为 2 的 `match:love`。 |
There was a problem hiding this comment.
搜索结果是索引为 2 的 match:love => 在字符串的第 2 个位置上搜索到了 match:love。
| alert( reg.lastIndex ); // 0 (default) | ||
| alert( str.match(reg) ); // null, not found at position 0 | ||
| alert( reg.lastIndex ); // 0(默认) | ||
| alert( str.match(reg) ); // null, 但是不位置0 |
| `y` 修饰符在给定位置应用一个正则表达式(或者会有很多,逐个进行),当我们理解了其中的内容后,就可以继续一步步检查文本。 | ||
|
|
||
| Without the flag the regexp engine always searches till the end of the text, that takes time, especially if the text is large. So our parser would be very slow. The `y` flag is exactly the right thing here. | ||
| 在没有该修饰符的情况下,引擎总是会检查到文本的末尾,这需要花费时间,尤其是文本很大的时候,所以解析器可能会很慢。`y` 修饰符在这里使用则恰到好处。 |
| `y` 修饰符在给定位置应用一个正则表达式(或者会有很多,逐个进行),当我们理解了其中的内容后,就可以继续一步步检查文本。 | ||
|
|
||
| Without the flag the regexp engine always searches till the end of the text, that takes time, especially if the text is large. So our parser would be very slow. The `y` flag is exactly the right thing here. | ||
| 在没有该修饰符的情况下,引擎总是会检查到文本的末尾,这需要花费时间,尤其是文本很大的时候,所以解析器可能会很慢。`y` 修饰符在这里使用则恰到好处。 |
| ## 总结,方法 | ||
|
|
||
| Methods become much easier to understand if we separate them by their use in real-life tasks. | ||
| 如果我们把这些方法通过实际任务中的使用进行拆解,就会更容易理解。 |
There was a problem hiding this comment.
如果我们把这些方法通过实际任务中的使用进行拆解, => 如果我们按照这些方法在实际任务中的用途划分,
Member
|
@BriFuture 很赞,欢迎多认领本教程的校对。 |
Member
|
@athena0304 可以修改啦 |
Contributor
Author
|
感谢校对者的修改意见~ |
|
376 行没有对修改/保留原译文作说明,你看看,没有其它问题了 @athena0304 |
|
@leviding 修改完毕,没有问题了 |
leviding
approved these changes
Sep 17, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
翻译完成
resolve #218