A wrapper to validate regular expressions and handle PCRE compilation errors.