Where the regular match string appears

A repeated string appears many times in a paragraph. How can I get the location of the repeated string each time?

is there a regular way to do it?

this is an insertion position {08} 66 insertion position {08} 66 insertion position {16} 66

for example, the above string

what I want is the insertion position {08} every occurrence
for example, the above string needs to get the following result
original text: this is a 666666
occurrence string: [{text: "insertion position {08}", index: 3, order: 1}, {text: "insertion position {08}", index: 6, order: 2}, {text: "insertion position {16}", index: 8, order: 3}]

Oct.27,2021

var reg = new RegExp(/66/g)
reg.exec('666666') // ["66", index: 0, input: "666666", groups: undefined]
reg.exec('666666') // ["66", index: 2, input: "666666", groups: undefined]
reg.exec('666666') // ["66", index: 4, input: "666666", groups: undefined]
reg.exec('666666') // null
Menu