var re = /ja|av|va/g; var s = "java"; var allResults = []; var result; while( result = re.exec( s ) ) { allResults.push( result[0] ); re.lastIndex = result.index + 1; } alert( allResults );