Skip to content

Commit 95a4b67

Browse files
authored
9-regular-expressions tiny update (#590)
* object#copying-by-reference - Comparison by reference:tiny translation issue * tiny update & 05-array-methods: add task 12-reduce-object * Sync with English Version: MDN has Array.prototype.values() * regex:tiny proofreading * change request edit line 95
1 parent dbea555 commit 95a4b67

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

1-js/05-data-types/09-keys-values-entries/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
- `Map`
1313
- `Set`
14-
- `Array`(除了 `arr.values()`
14+
- `Array`
1515

1616
纯对象也支持类似的方法,但是语法上有一些不同
1717

1-js/05-data-types/11-date/6-get-seconds-today/task.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ importance: 5
1212
getSecondsToday() == 36000 // (3600 * 10)
1313
```
1414

15-
该函数应该在任意一天都能正确运行。那意味着,不应该有一个「今天」这个参数不能有意外值
15+
该函数应该在任意一天都能正确运行。那意味着,它不应具有「今天」的硬编码值

9-regular-expressions/05-regexp-multiline-mode/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ alert( str.match(/\w+$/gim) ); // Winnie,Piglet,Eeyore
5555

5656
## 锚符 ^$ 对比 \n
5757

58-
要寻找新的一行的话,我们不仅可以使用锚符 `^``$`也可以使用批匹配符 `\n`
58+
要寻找新的一行的话,我们不仅可以使用锚符 `^``$`也可以使用换行符 `\n`
5959

6060
它和锚符 `^``$` 的第一个不同点是它不像锚符那样,它会“消耗”掉 `\n` 并且将其(`\n`)加入到匹配结果中。
6161

9-regular-expressions/07-regexp-escaping/article.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@ alert( "Chapter 5.1".match(regexp) ); // 5.1
9090

9191
## Summary
9292

93-
- To search for special characters `pattern:[ \ ^ $ . | ? * + ( )` literally, we need to prepend them with a backslash `\` ("escape them").
94-
- We also need to escape `/` if we're inside `pattern:/.../` (but not inside `new RegExp`).
95-
- When passing a string `new RegExp`, we need to double backslashes `\\`, cause string quotes consume one of them.
93+
- 要在字面(意义)上搜索特殊字符 `pattern:[ \ ^ $ . | ? * + ( )`,我们需要在它们前面加上反斜杠 `\`("转义它们")。
94+
- 如果我们在 `pattern:/.../` 内部(但不在 `new RegExp` 内部),还需要转义 `/`
95+
- 传递一个字符串(参数)给 `new RegExp` 时,我们需要双倍反斜杠 `\\`,因为字符串引号会消费其中的一个。

9-regular-expressions/08-regexp-character-sets-and-ranges/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ alert( "Voila".match(/V[oi]la/) ); // null,并没有匹配上
2626

2727
- `pattern:V`
2828
- 然后匹配其中的**一个字符** `pattern:[oi]`
29-
- 然后匹配 `pattern:V`
29+
- 然后匹配 `pattern:la`
3030

3131
所以可以匹配上 `match:Vola` 或者 `match:Vila`
3232

9-regular-expressions/09-regexp-quantifiers/2-find-html-colors-6hex/solution.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ let str = "color:#121212; background-color:#AA00ef bad-colors:f#fddee #fd2"
1414
alert( str.match(reg) ); // #121212,#AA00ef
1515
```
1616

17-
问题是匹配到颜色值过长
17+
问题是其从更长的序列中匹配了颜色值
1818

1919
```js run
20-
alert( "#12345678".match( /#[a-f0-9]{6}/gi ) ) // #12345678
20+
alert( "#12345678".match( /#[a-f0-9]{6}/gi ) ) // #123456
2121
```
2222

2323
为了解决这个问题,我们可以在末尾加上 `pattern:\b`

9-regular-expressions/10-regexp-greedy-and-lazy/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ alert( str.match(reg) ); // witch, broom
142142

143143
![](witch_lazy6.svg)
144144

145-
在这个例子中,我们看到了懒惰模式 `pattern:+?` 是怎样工作的。量词 `pattern:+?``pattern:??` 也有类似的效果 —— 只有在模式的剩余部分无法在给定位置匹配时,正则表达式引擎才会增加重复次数。
145+
在这个例子中,我们看到了懒惰模式 `pattern:+?` 是怎样工作的。量词 `pattern:*?``pattern:??` 也有类似的效果 —— 只有在模式的剩余部分无法在给定位置匹配时,正则表达式引擎才会增加重复次数。
146146

147147
**懒惰模式只能够通过带 `?` 的量词启用**
148148

9-regular-expressions/11-regexp-groups/02-find-webcolor-3-or-6/solution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ let reg = /#([a-f0-9]{3}){1,2}\b/gi;
2525

2626
let str = "color: #3f3; background-color: #AA00ef; and: #abcd";
2727

28-
alert( str.match(reg) ); // #3f3 #AA0ef
28+
alert( str.match(reg) ); // #3f3 #AA00ef
2929
```

0 commit comments

Comments
 (0)