private function sanitizePattern($name, $pattern)
    {
        // make sure value is a string
        if (!$this->isString($pattern)) {
            throw new RouterException('The value of %s.%s option must be a string.', [
                    $this->name,
                    $name
                ]
            );
        }

        // filter out some characters from the start and end of the pattern
        $pattern = $this->str($pattern)->trimLeft('^')->trimRight('$');

        // make sure pattern is not empty
        if ($pattern->length() < 1) {
            throw new RouterException('The route for %s.%s cannot be empty.', [
                    $this->name,
                    $name
                ]
            );
        }

        return $pattern->val();
    }