improved regex capture group matching and highlighting