private function validateStartLength($start, $length)
    {
        $_startEnd = [];
        if (preg_match('/[0-9]/', $start)) {
            $_startEnd[0] = (int) $start;
        } elseif ('#' === $start) {
            $_startEnd[0] = '#';
        } else {
            throw new \UnexpectedValueException(
                'First argument must be positive int, 0 or character #.',
                $start
            );
        }

        if (preg_match('/^[1-9]\d*/', $length)) { // only positive int without 0
            $_startEnd[1] = (int) $length - 1;
        } else {
            throw new \UnexpectedValueException(
                'Second argument must be positive int without 0.',
                $length
            );
        }

        return $_startEnd;
    }
private function validateStartLength($start, $length)
    {
        $_startEnd = [];
        if (preg_match('/[0-9]/', $start)) {
            $_startEnd[0] = (int) $start;
        } elseif ('#' === $start) {
            $_startEnd[0] = '#';
        } else {
            throw new \UnexpectedValueException(
                'First argument must be positive int, 0 or character #.',
                $start
            );
        }

        if (preg_match('/^[1-9]\d*/', $length)) { // only positive int without 0
            $_startEnd[1] = (int) $length - 1;
        } else {
            throw new \UnexpectedValueException(
                'Second argument must be positive int without 0.',
                $length
            );
        }

        return $_startEnd;
    }
private function validateStartLength ( $ start , $ length ) { $ _startEnd = [ ] ; if ( preg_match ( '/[0-9]/' , $ start ) ) { $ _startEnd [ 0 ] = ( int ) $ start ; } elseif ( '#' === $ start ) { $ _startEnd [ 0 ] = '#' ; } else { throw new \ UnexpectedValueException ( 'First argument must be positive int, 0 or character #.' , $ start ) ; } if ( preg_match ( '/^[1-9]\d*/' , $ length ) ) { // only positive int without 0 $ _startEnd [ 1 ] = ( int ) $ length - 1 ; } else { throw new \ UnexpectedValueException ( 'Second argument must be positive int without 0.' , $ length ) ; } return $ _startEnd ; }
Validate starting position and length.

@internal

@param string $start  The starting position
@param string $length $length The length count

@throws \UnexpectedValueException

@return array $_startEnd index 0 => start, index 1 => end
Validate starting position and length .