var rx = /\[color=([^\]]+)\](.*?)(?:\[\/color\]|$)/g;
var array_action = [];
var totalRemove = 0;
var resultStr = str.replace(rx, function(a, color, txt, idx) {
array_action.push({
index_start_action: idx - totalRemove,
index_end_action: idx + txt.length - totalRemove
});
totalRemove += color.length + 16;
return txt;
});