Fixed possibly empty regex bug