/o([0-9]+?)__/g
Give this a try. Check it out here and look for "lazy star".
var rx = new RegExp( /o([0-9]+?)__/g );
var txt = "Local residents o1__have called g__in o22__with reports...";
var mtc = [];
while( (match = rx.exec( txt )) != null ) {
alert( match[1] );
mtc.push(match[1]);
}
Jek-fdrv mentioned in the comments that calling rx.test just before the while loop can skip some results. This is because the RegExp object has a lastIndex field that tracks the index of the last match in the string. When lastIndex changes, the RegExp continues matching from that updated index, causing part of the string to be skipped. Here's a simple example:
var rx = new RegExp( /o([0-9]+?)__/g );
var txt = "Local residents o1__have called g__in o22__with reports...";
var mtc = [];
console.log(rx.test(txt), rx.lastIndex); //outputs "true 20"
console.log(rx.test(txt), rx.lastIndex); //outputs "true 43"
console.log(rx.test(txt), rx.lastIndex); //outputs "false 0" !!!
rx.lastIndex = 0; //manually resetting lastIndex field works in Chrome
//now everything works smoothly
while( (match = rx.exec( txt )) != null ) {
console.log( match[1] );
mtc.push(match[1]);
}