- /**
- * Validate that $pattern is a valid regular expression.
- *
- * @param string $pattern
- *
- * @return bool
- */
- private function validateRegex($pattern)
- {
- set_error_handler(array('Psy\Exception\ErrorException', 'throwException'));
- try {
- preg_match($pattern, '');
- } catch (ErrorException $e) {
- throw new RuntimeException(str_replace('preg_match(): ', 'Invalid regular expression: ', $e->getRawMessage()));
- }
- restore_error_handler();
- }
-