Curves in projective spaces and their index of regularity