changing matrix regex to lazy instead of greedy search