Made some improvements to regex escaping