Skip to content

Commit

Permalink
typo: match -> match()
Browse files Browse the repository at this point in the history
  • Loading branch information
xt1995726 committed Jun 30, 2022
1 parent f45f032 commit d4d888e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/regex.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ RE_TWICE.test('abc!abc!ab') // false

正则匹配的结果,在原始字符串里面的开始位置和结束位置,目前获取并不是很方便。正则实例的`exec()`方法的返回结果,现有一个`index`属性,可以获取整个匹配结果的开始位置。但是,组匹配的每个组的开始位置,很难拿到。

[ES2022](https://github.com/tc39/proposal-regexp-match-Indices) 中新增`d`修饰符,使用`/d`修饰符,为`exec()``match`等方法的返回结果加上`indices`属性,在这个属性上面可以拿到匹配的开始位置和结束位置。
[ES2022](https://github.com/tc39/proposal-regexp-match-Indices) 中新增`d`修饰符,使用`/d`修饰符,为`exec()``match()`等方法的返回结果加上`indices`属性,在这个属性上面可以拿到匹配的开始位置和结束位置。

```javascript
const text = 'zabbcdef';
Expand Down

0 comments on commit d4d888e

Please sign in to comment.