Returns a part of the string and quotes it.
@param string  $s     The string to use
@param integer $start The start index
@param integer $end   The end index
@return string
430215
protected function quote($s, $start, $end)
    {
        if ($start == $end) {
            return "";
        }
        return preg_quote(substr($s, $start, $end), '#');
    }
542791
public static function lines($text, $start, $end)
	{
		$lines      = explode(PHP_EOL, $text);
		$code       = implode(PHP_EOL, array_slice($lines, $start - 1, $end - $start + 1));
		return $code;
	}
360804
public function substr($start = 0, $length = null)
    {
        $function = static::$functions[(int) static::$useMbstring]['substr'];

        return new self($function($this->string, $start, $length));
    }
216408
public static function substr(string $str, int $start=0, $length=null) {
		if (\function_exists('mb_substr')) {
			return \mb_substr($str, $start, $length, 'UTF-8');
		}

		return \substr($str, $start, $length);
	}
466409
public function substr($start, $length = null, $encoding = null)
    {
        if (!$this->hasMbstring()) {
            return $this->transform('\substr', $start, $length);
        }

        $encoding = $this->encoding($encoding);

        // workaround for php < 5.4.8
        if (is_null($length)) {
            $length = \mb_strlen($this->string, $encoding);
        }

        return $this->transform('\mb_substr', $start, $length, $encoding);
    }
916252
public static function truncate_two($str, $start, $length = null)
    {
        if (!$length) {
            $length = $start;
            $start = 0;
        }

        if (\strlen($str) <= $length) {
            return $str;
        }

        if (\function_exists('mb_substr')) {
            $str = mb_substr(strip_tags($str), $start, $length, 'utf-8');
        } else {
            $str = substr($str, $start, $length) . '...';
        }

        return $str;
    }
737581
public static function obfuscate($string, $start = 0, $end = 3, $replacement = '*'): string
    {
        $len = \strlen($string);

        if ($start < 0) {
            $start += $len;
        }
        $start = min($start, $len - 1);

        if ($end < 0) {
            $end += $len;
        }
        $end = min($end, $len - 1);

        if (0 === $len || $len === $start + 1 || $len === $end + 1 || $len <= $start + $end) {
            return $string;
        }

        return substr($string, 0, $start).str_repeat($replacement, $len - $end - $start).substr($string, $len - $end, $end);
    }
1158037
public function readToken($start)
    {
        $length = $this->source->getLength();
        $position = $this->positionAfterWhitespace($start);

        if ($position >= $length) {
            return new Token(Token::EOF_TYPE, $length, $length);
        }

        $code = $this->charCodeAt($position);

        switch ($code) {
            // !
            case 33:
                return new Token(Token::BANG_TYPE, $position, $position + 1);
            // $
            case 36:
                return new Token(Token::DOLLAR_TYPE, $position, $position + 1);
            // (
            case 40:
                return new Token(Token::PAREN_L_TYPE, $position, $position + 1);
            // )
            case 41:
                return new Token(Token::PAREN_R_TYPE, $position, $position + 1);
            // .
            case 46:
                if ($this->charCodeAt($position + 1) === 46 && $this->charCodeAt($position + 2) === 46) {
                    return new Token(Token::SPREAD_TYPE, $position, $position + 3);
                }
                break;
            // :
            case 58:
                return new Token(Token::COLON_TYPE, $position, $position + 1);
            // =
            case 61:
                return new Token(Token::EQUALS_TYPE, $position, $position + 1);
            // @
            case 64:
                return new Token(Token::AT_TYPE, $position, $position + 1);
            // [
            case 91:
                return new Token(Token::BRACKET_L_TYPE, $position, $position + 1);
            // ]
            case 93:
                return new Token(Token::BRACKET_R_TYPE, $position, $position + 1);
            // {
            case 123:
                return new Token(Token::BRACE_L_TYPE, $position, $position + 1);
            // |
            case 124:
                return new Token(Token::PIPE_TYPE, $position, $position + 1);
            // }
            case 125:
                return new Token(Token::BRACE_R_TYPE, $position, $position + 1);
            // A-Z
            case 65: case 66: case 67: case 68: case 69: case 70: case 71: case 72:
            case 73: case 74: case 75: case 76: case 77: case 78: case 79: case 80:
            case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88:
            case 89: case 90:
            // _
            case 95:
            // a-z
            case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104:
            case 105: case 106: case 107: case 108: case 109: case 110: case 111:
            case 112: case 113: case 114: case 115: case 116: case 117: case 118:
            case 119: case 120: case 121: case 122:
                return $this->readName($position);
            // -
            case 45:
            // 0-9
            case 48: case 49: case 50: case 51: case 52:
            case 53: case 54: case 55: case 56: case 57:
                return $this->readNumber($position, $code);
            // "
            case 34:
                return $this->readString($position);
        }

        // @todo Throw proper exception.
        throw new \Exception('Unexpected character.');
    }
232632
protected function doesStartOrEndWithSingleQuote($name)
    {
        $startsWithSingleQuote = ($this->stringHelper->getCharFirstOccurrencePosition('\'', $name) === 0);
        $endsWithSingleQuote = ($this->stringHelper->getCharLastOccurrencePosition('\'', $name) === ($this->stringHelper->getStringLength($name) - 1));

        return ($startsWithSingleQuote || $endsWithSingleQuote);
    }
33589
public static function substr(string $string, int $start, int $length = null)
    {
        if ($length === 0) {
            return '';
        }

        // Cannot omit $length, when specifying charset
        if ($length === null) {
            // save internal encoding
            $enc = mb_internal_encoding();
            mb_internal_encoding('UTF-8');
            $str = mb_substr($string, $start);
            // restore internal encoding
            mb_internal_encoding($enc);

            return $str;
        }

        return mb_substr($string, $start, $length, 'UTF-8');
    }
212654
public String substring(int start, int end) {

    return new String(this.buffer, this.initialOffset + start, end - start);
  }
113727
public function getBetweenReverse($content, $start, $end)
    {
        $endIndex = strrpos($content, $end);
        $startIndex = strrpos($content, $start, -1 * (strlen($content) - $endIndex)) + strlen($start);
        return substr($content, $startIndex, $endIndex - $startIndex);
    }
459280
public function subSequence(int $start, int $end) {
        $arrayList = $this->arrayList->subList($start, $end);
        $stringBuilder = $this->arrayListToStringBuilder($arrayList);
        return $stringBuilder;
    }
1057795
public static function join($strings, $separator, $start = 0, $count = -1)
    {
        $string = '';

        $end = $count == -1 ? Collection::count($strings) : $count;

        for ($i = $start; $i < $end; $i++) {
            $string .= $strings[$i].$separator;

            if ($i == ($end - 1)) {
                $string .= $separator;
            }
        }

        return $string;
    }
1176034
function _substr($string, $start, $length = null) {
        static $mbstring;

        // Cache expensive function_exists() calls.
        if (!isset($mbstring)) {
            $mbstring = function_exists('mb_substr');
        }

        if (is_null($length)) {
            $length = $this->_strlen($string);
        }
        if ($mbstring) {
            $ret = @mb_substr($string, $start, $length, $this->_charset);
            if (!empty($ret)) {
                return $ret;
            }
        }
        return substr($string, $start, $length);
    }
718709
private function find_string($string, $start = -1, $end = -1) {
        if (($start == -1) or ($end == -1)) {
            // find_string is called with only one parameter, set start end end
            $start = 0;
            $end = $this->total;
        }
        if (abs($start - $end) <= 1) {
            // We're done, now we either found the string, or it doesn't exist
            $txt = $this->get_original_string($start);
            if ($string == $txt)
                return $start;
            else
                return -1;
        }
        else if ($start > $end) {
            // start > end -> turn around and start over
            return $this->find_string($string, $end, $start);
        }
        else {
            // Divide table in two parts
            $half = (int)(($start + $end) / 2);
            $cmp = strcmp($string, $this->get_original_string($half));
            if ($cmp == 0)
                // string is exactly in the middle => return it
                return $half;
            else if ($cmp < 0)
                // The string is in the upper half
                return $this->find_string($string, $start, $half);
            else
                // The string is in the lower half
                return $this->find_string($string, $half, $end);
        }
    }
613675
public function getrange($key, $start, $end) {
        return $this->returnCommand(['GETRANGE'], $key, [$key, $start, $end]);
    }