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

typo: match -> match()

This commit is contained in:
xt1995726 2022-06-30 20:46:54 +08:00
parent f45f032a23
commit d4d888e94e

View File

@ -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';