fix error checking for \ at end of regex (this was broken previously)