Returns cut down part of [[$content]].

@param integer $limit
@return string
329252
public function getLimitedContent( $limit = CoreGlobal::DISPLAY_TEXT_MEDIUM ) {

		$content = $this->content;

		if( strlen( $content ) > $limit ) {

			$content = substr( $content, 0, $limit );
		}

		return HtmlPurifier::process( $content );
	}
13362
protected function _censor($content) {
        $pattern = implode('|', array_map(array($this, '_prepareRegex'), $this->getBlacklist()));
        $content = preg_replace_callback('/(?:^|\b)(?:' . $pattern . ')(?:\b|$)/is', array($this, '_censorCallback'), $content);

        return $content;
    }
1260616
public function parse($content)
    {
        $set = null;
        if (strpos($content, '@ORM') === false) {
            return $set;
        }

        if (preg_match(self::PATTERN, $content, $matches)) {
            $set[] = [$matches[1], $matches[2]];
        }



        return $set;
    }
760799
public function substring($start, $end = null)
    {
        if ($end === null) {
            return substr($this->content, $start);
        }
        $len = $end - $start;
        if ($len < 0) {
            return '';
        }
        return substr($this->content, $start, $len);
    }
893721
public static function summary($str, $limit=100, $strip = false) {
		$str = ($strip == true) ? strip_tags($str) : $str;
		return static::truncate($str, $limit - 3, '...');
	}
1134326
private function clean($content)
    {
        // line feed
        $content = str_replace("\r\n", "\n", $content);
     
        // trailing whitespaces
        $content = preg_replace('/[ \t]*$/m', '', $content);

        // indentation
        $content = preg_replace_callback('/^([ \t]+)/m', function ($matches) use ($content) {
            return str_replace("\t", '    ', $matches[0]);
        }, $content);

        // Unused "use" statements
        preg_match_all('/^use (?P<class>[^\s;]+)(?:\s+as\s+(?P<alias>.*))?;/m', $content, $matches, PREG_SET_ORDER);
        foreach ($matches as $match) {
            if (isset($match['alias'])) {
                $short = $match['alias'];
            } else {
                $parts = explode('\\', $match['class']);
                $short = array_pop($parts);
            }

            preg_match_all('/\b'.$short.'\b/i', str_replace($match[0]."\n", '', $content), $m);
            if (!count($m[0])) {
                $content = str_replace($match[0]."\n", '', $content);
            }
        }

        // end of line
        if (strlen($content) && "\n" != substr($content, -1)) {
            $content = $content."\n";
        }

        return $content;
    }
1362689
public function getPreview($limit = 50)
    {
        $string = trim(preg_replace("/\r|\n/", " ", strip_tags($this->getContent())));
        $words = explode(" ", $string);
        $append = ' ... <br/><a href="'.$this->getURL().'" title="Read more" id="readmorelink">Read more</a>'; // TODO move into template
        return implode(" ", array_splice($words, 0, $limit)) . $append;
    }
237376
private static function truncateStr($str, $limit)
    {
        if (strlen($str) > $limit) {
            return substr($str, 0, $limit) . '...';
        }
        return $str;
    }
544367
public static function cutWords(string $string, int $limit = 25, string $append = '...'): string
    {
        preg_match('/^\s*+(?:\S++\s*+){1,' . $limit . '}/u', $string, $matches);
        if (!isset($matches[0]) || mb_strlen($string, 'UTF-8') === mb_strlen($matches[0], 'UTF-8')) {
            return $string;
        }

        return rtrim($matches[0]) . $append;
    }
836014
public function truncate(int $maximum) : Text
    {
        return $this->pipe(
            function (string $value) use ($maximum) : string {
                return strlen($value) > $maximum
                    ? substr($value, 0, $maximum)
                    : $value;
            }
        );
    }
591886
public static function limit( $value, $limit = 100, $end = '...' )
    {
        if ( mb_strlen( $value ) <= $limit )
        {
            return $value;
        }

        return rtrim( mb_substr( $value, 0, $limit, 'UTF-8' ) ) . $end;
    }
808686
public static function cut(string $string, int $limit = 25, string $append = '...'): string
    {
        if (mb_strlen($string, 'UTF-8') <= $limit) {
            return $string;
        }

        return rtrim(mb_substr($string, 0, $limit, 'UTF-8')) . $append;
    }
464340
private function tokenize($input, $limit = -1)
    {
        $chunks = preg_split('!\s+!', $input, $limit);
        if ($limit !== -1 && count($chunks) != $limit) {
            $chunks += array_fill(count($chunks), $limit, '');
        }
        return $chunks;
    }
664008
public function take($limit)
    {
        if (is_null($this->limit)) {
            $this->limit = (int) $limit;

            return $this;
        }

        if (preg_match('/^([\d]+),\s$/', $this->limit, $match)) {
            $this->limit = end($match).', '.$limit;
        }

        return $this;
    }
959693
public function getContent($limit = 0)
    {
        return $this->getESAdaptor()->getDocuments($this->getRegistryIndex($this->section), $limit);
    }
749844
public static function getIndent($content)
    {
        $indent = self::DEFAULT_INDENT;
        preg_match(self::INDENT_REGEX, trim($content), $matches);

        if (!empty($matches)) {
            $indent = \strlen($matches[1]);
        }

        return $indent;
    }
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);
    }