Optimizing for regex