Stringy\Stringy::between PHP Method

between() public method

Returns the substring between $start and $end, if found, or an empty string. An optional offset may be supplied from which to begin the search for the start string.
public between ( string $start, string $end, integer $offset ) : Stringy
$start string Delimiter marking the start of the substring
$end string Delimiter marking the end of the substring
$offset integer Index from which to begin the search
return Stringy Object whose $str is a substring between $start and $end
    public function between($start, $end, $offset = 0)
    {
        $startIndex = $this->indexOf($start, $offset);
        if ($startIndex === false) {
            return static::create('', $this->encoding);
        }
        $substrIndex = $startIndex + \mb_strlen($start, $this->encoding);
        $endIndex = $this->indexOf($end, $substrIndex);
        if ($endIndex === false) {
            return static::create('', $this->encoding);
        }
        return $this->substr($substrIndex, $endIndex - $substrIndex);
    }