正则小记
const r1 = /abc/g //全局寻找abc
const r2 = /abc/y //只有abc是相连的才会被匹配到
const str = 'abcabc-abc'
//
console.log(r1.exec(str))
console.log(r1.exec(str))
console.log(r1.exec(str))
//["abc", index: 0, input: "abcabc-abc", groups: undefined]
//["abc", index: 3, input: "abcabc-abc", groups: undefined]
//["abc", index: 7, input: "abcabc-abc", groups: undefined]
console.log(r2.exec(str))
console.log(r2.exec(str))
console.log(r2.exec(str))
//["abc", index: 0, input: "abcabc-abc", groups: undefined]
//["abc", index: 3, input: "abcabc-abc", groups: undefined]