Compile regex instead of interpret every loop