1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

docs(regex): edit regex

This commit is contained in:
ruanyf 2018-03-02 12:42:37 +08:00
parent 53389645e7
commit b4f1226178

View File

@ -182,7 +182,7 @@ match.index // 3
REGEX.lastIndex // 4
// 4号位开始匹配失败
REGEX.exec('xaxa') // null
REGEX.exec('xaya') // null
```
上面代码中,`lastIndex`属性指定每次搜索的开始位置,`g`修饰符从这个位置开始向后搜索,直到发现匹配为止。
@ -202,7 +202,7 @@ REGEX.exec('xaya') // null
REGEX.lastIndex = 3;
// 3号位置是粘连匹配成功
const match = REGEX.exec('xaxa');
const match = REGEX.exec('xaya');
match.index // 3
REGEX.lastIndex // 4
```