public static function preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
    {
        if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) {
            switch (preg_last_error()) {
                case PREG_INTERNAL_ERROR:
                    $error = 'Internal PCRE error.';
                    break;
                case PREG_BACKTRACK_LIMIT_ERROR:
                    $error = 'pcre.backtrack_limit reached.';
                    break;
                case PREG_RECURSION_LIMIT_ERROR:
                    $error = 'pcre.recursion_limit reached.';
                    break;
                case PREG_BAD_UTF8_ERROR:
                    $error = 'Malformed UTF-8 data.';
                    break;
                case PREG_BAD_UTF8_OFFSET_ERROR:
                    $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.';
                    break;
                default:
                    $error = 'Error.';
            }

            throw new ParseException($error);
        }

        return $ret;
    }
public static function preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
    {
        if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) {
            switch (preg_last_error()) {
                case PREG_INTERNAL_ERROR:
                    $error = 'Internal PCRE error.';
                    break;
                case PREG_BACKTRACK_LIMIT_ERROR:
                    $error = 'pcre.backtrack_limit reached.';
                    break;
                case PREG_RECURSION_LIMIT_ERROR:
                    $error = 'pcre.recursion_limit reached.';
                    break;
                case PREG_BAD_UTF8_ERROR:
                    $error = 'Malformed UTF-8 data.';
                    break;
                case PREG_BAD_UTF8_OFFSET_ERROR:
                    $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.';
                    break;
                default:
                    $error = 'Error.';
            }

            throw new ParseException($error);
        }

        return $ret;
    }
public static function preg_match ( $ pattern , $ subject , & $ matches = null , $ flags = 0 , $ offset = 0 ) { if ( false === $ ret = preg_match ( $ pattern , $ subject , $ matches , $ flags , $ offset ) ) { switch ( preg_last_error ( ) ) { case PREG_INTERNAL_ERROR : $ error = 'Internal PCRE error.' ; break ; case PREG_BACKTRACK_LIMIT_ERROR : $ error = 'pcre.backtrack_limit reached.' ; break ; case PREG_RECURSION_LIMIT_ERROR : $ error = 'pcre.recursion_limit reached.' ; break ; case PREG_BAD_UTF8_ERROR : $ error = 'Malformed UTF-8 data.' ; break ; case PREG_BAD_UTF8_OFFSET_ERROR : $ error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.' ; break ; default : $ error = 'Error.' ; } throw new ParseException ( $ error ) ; } return $ ret ; }
A local wrapper for `preg_match` which will throw a ParseException if there
is an internal error in the PCRE engine.

This avoids us needing to check for "false" every time PCRE is used
in the YAML engine

@throws ParseException on a PCRE internal error

@see preg_last_error()

@internal
A local wrapper for preg_match which will throw a ParseException if there is an internal error in the PCRE engine .