) {
this.data = iterable
}
async *[Symbol.asyncIterator]() {
let length = this.data.length...可以匹配任意单个字符:
/foo.bar/.test('foo\nbar') // false
/foo.bar/s.test('foo\nbar') // true
上面这又被称为 dotAll.../g
let iterable = str.matchAll(regexp)
for (const x of iterable) {
console.log(x)
}
// ['test1',...'e', 'st1', '1', index: 0, input: 'test1test1', groups: undefined]
// ['test2', 'e', 'st2', '2', index...: 5, input: 'test1test2', groups: undefined]
❝注意当使用 matchAll(regexp) 的时候,正则表达式必须加上 /g 修饰符。