Skip to content

Commit 919a1cd

Browse files
committed
feat: update translation
1 parent b57f2eb commit 919a1cd

File tree

7 files changed

+121
-128
lines changed

7 files changed

+121
-128
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
结果是:`match:123 4`
33

4-
首先,懒惰模式 `pattern:\d+?` 尝试去获取尽可能少的字符,但当它检测到空格,就得出匹配结果 `match:123`
4+
首先,惰性模式 `pattern:\d+?` 尝试去获取尽可能少的数字,但它必须到达空格,因此需要匹配到 `match:123`
55

6-
然后,第二个 `\d+?` 就只获取一个字符,因为这就已足够了
6+
然后,第二个 `\d+?` 就只获取一个数字,因为这就已经足够了

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# 对于 /d+? d+?/ 的匹配
1+
# /d+? d+?/ 的匹配项
22

3-
以下匹配的结果是什么
3+
匹配的结果是什么
44

55
```js
66
alert( "123 456".match(/\d+? \d+?/g) ); // ?
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
我们需要找到注释的起始位置 `match:<!--`,然后获取字符直到注释的末尾 `match:-->`
22

3-
首先想到的是 `pattern:<!--.*?-->` —— 惰性量词使得点(.)停在 `match:-->` 之前。
3+
行得通的表达式可以是 `pattern:<!--.*?-->` —— 惰性量词使得点在 `match:-->` 之前 停止。我们还需要为点添加修饰符 `pattern:s` 以包含换行符
44

5-
但是在 Javascript 中,一个点(.)表示除换行符之外的任意字符。所以这是无法匹配多行注释的。
6-
7-
我们可以用 `pattern:[\s\S]`,而不是用点(.)来匹配“任何东西”:
5+
否则找不到多行注释:
86

97
```js run
10-
let reg = /<!--[\s\S]*?-->/g;
8+
let regexp = /<!--.*?-->/gs;
119

1210
let str = `... <!-- My -- comment
1311
test --> .. <!----> ..
1412
`;
1513

16-
alert( str.match(reg) ); // '<!-- My -- comment \n test -->', '<!---->'
14+
alert( str.match(regexp) ); // '<!-- My -- comment \n test -->', '<!---->'
1715
```
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# 查找 HTML 注释
22

3-
找出文本中的所有注释
3+
找出文本中的所有 HTML 注释
44

55
```js
6-
let reg = /你的正则表达式/g;
6+
let regexp = /你的正则表达式/g;
77

88
let str = `... <!-- My -- comment
99
test --> .. <!----> ..
1010
`;
1111

12-
alert( str.match(reg) ); // '<!-- My -- comment \n test -->', '<!---->'
12+
alert( str.match(regexp) ); // '<!-- My -- comment \n test -->', '<!---->'
1313
```

9-regular-expressions/10-regexp-greedy-and-lazy/4-find-html-tags-greedy-lazy/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
答案是 `pattern:<[^<>]+>`
33

44
```js run
5-
let reg = /<[^<>]+>/g;
5+
let regexp = /<[^<>]+>/g;
66

77
let str = '<> <a href="/"> <input type="radio" checked> <b>';
88

9-
alert( str.match(reg) ); // '<a href="/">', '<input type="radio" checked>', '<b>'
9+
alert( str.match(regexp) ); // '<a href="/">', '<input type="radio" checked>', '<b>'
1010
```
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# 寻找 HTML 标签
22

3-
创建一个正则表达式语句来寻找所有具有其属性的(闭合或非闭合)HTML 标签
3+
创建一个正则表达式来寻找所有(开始和结束)HTML 标签及其特性
44

55
用例:
66

77
```js run
8-
let reg = /你的正则表达式/g;
8+
let regexp = /你的正则表达式/g;
99

1010
let str = '<> <a href="/"> <input type="radio" checked> <b>';
1111

12-
alert( str.match(reg) ); // '<a href="/">', '<input type="radio" checked>', '<b>'
12+
alert( str.match(regexp) ); // '<a href="/">', '<input type="radio" checked>', '<b>'
1313
```
1414

15-
假设标签属性中不会包含 `<``>`(包括被引号包裹的内容),这样就简单许多
15+
这里我们假设标签特征中不包含 `<``>`(包括被引号包裹的内容),这样就简单多了

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

Lines changed: 104 additions & 109 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)