Get text until <!--more--> or all text.

@param string $text with content

@return array with text and boolean if more was detected.
331632
public function getUntilMore($text)
    {
        $pos = stripos($text, "<!--more-->");
        $hasMore = $pos;
        if ($pos) {
            $text = substr($text, 0, $pos);
        }
        return [$text, $hasMore];
    }
625535
protected static function checkColons($text)
    {
        if (strpos($text, ':') !== false
        || strpos($text, '[') !== false
        || strpos($text, '{') !== false
        || strpos($text, '-') !== false
        || strpos($text, '<') !== false
        || strpos($text, '&') !== false
        ) {
            return '"'.str_replace('"', '\"', $text).'"';
        }

        return $text;
    }
1131200
public function prompt($text) {

        // send out any escaping to implement anything sitting in the desired state
        $this->outputEscapeSequence();

        // save off the prompt string
        $prompt = $text  . $this->promptCaret . " ";

        // prompt and return the answer
        return $this->readUserInput($prompt);

    }
821330
protected function processInline($text)
    {
        while($text) {
            if (preg_match(self::MATCH_LINK, $text, $m)) {
                return $this->processLink($text, $m[0]);
            }

            if( $this->lookAhead($text, self::STRONG_START_END) !== false ) {
                return $this->processStrong($text);
            }

            if ( $this->lookAhead($text, self::EMPHASIZED_START_END) !== false ) {
                return $this->processEmphasized($text);
            }

            $text = $this->processRestOfLine($text);
        }

        return ''; //All text is consumed
    }
515011
protected function processInline($text)
    {
        while ($text) {
            if (preg_match(self::MATCH_LINK, $text, $m)) {
                return $this->processLink($m[1], $m[2], $m[3], $m[4]);
            }

            $importantTextAhead = $this->lookAhead($text, self::STRONG_START_END);
            $emphasizedTextAhead = $this->lookAhead($text, self::EMPHASIZED_START_END);

            if ($importantTextAhead === false) {
                $importantTextAhead = $this->lookAhead($text, self::STRONG_START_END_TYPE_2);
            }

            if ($emphasizedTextAhead === false) {
                $emphasizedTextAhead = $this->lookAhead($text, self::EMPHASIZED_START_END_TYPE_2);
            }

            if ($importantTextAhead !== false && $emphasizedTextAhead !== false) {
                if ($importantTextAhead <= $emphasizedTextAhead) {
                    $unformattedText = mb_substr($text, 0, $importantTextAhead);
                    $importantText = mb_substr($text, $importantTextAhead);
                    $this->text($unformattedText);

                    return $this->processStrong($importantText);
                } else {
                    $unformattedText = mb_substr($text, 0, $emphasizedTextAhead);
                    $emphasizedText = mb_substr($text, $emphasizedTextAhead);
                    $this->text($unformattedText);

                    return $this->processEmphasized($emphasizedText);
                }
            } elseif ($importantTextAhead !== false) {
                $unformattedText = mb_substr($text, 0, $importantTextAhead);
                $importantText = mb_substr($text, $importantTextAhead);
                $this->text($unformattedText);

                return $this->processStrong($importantText);
            } elseif ($emphasizedTextAhead !== false) {
                $unformattedText = mb_substr($text, 0, $emphasizedTextAhead);
                $emphasizedText = mb_substr($text, $emphasizedTextAhead);
                $this->text($unformattedText);

                return $this->processEmphasized($emphasizedText);
            }

            $text = $this->processRestOfLine($text);
        };

        return ''; //All text is consumed
    }
555975
public function notSee($text)
    {
        return $this->assertSee($text, sprintf(
            "Could not find '%s' on the page, '%s'.", $text, $this->currentPage
        ), true);
    }
211420
protected function reduce(&$text) {
        if (!array_key_exists($this->stack->top(), $this->patterns)) {
            return false;
        }
        if ($text !== '' && ($data = $this->patterns[$this->stack->top()]->split($text)) !== false) {
            list($unmatched, $matched, $text, $childRuleName) = $data;

            return [$unmatched, $matched, $childRuleName];
        }

        return true;
    }
459347
function check($text)
    {
        $this->init();

        if (!$this->plink) {
            return array();
        }

        // tokenize
        $text = preg_split($this->separator, $text, NULL, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);

        $diff       = 0;
        $matches    = array();

        foreach ($text as $w) {
            $word = trim($w[0]);
            $pos  = $w[1] - $diff;
            $len  = mb_strlen($word);

            // skip exceptions
            if ($this->dictionary->is_exception($word)) {
            }
            else if (!pspell_check($this->plink, $word)) {
                $suggestions = pspell_suggest($this->plink, $word);

                if (count($suggestions) > self::MAX_SUGGESTIONS) {
                    $suggestions = array_slice($suggestions, 0, self::MAX_SUGGESTIONS);
                }

                $matches[] = array($word, $pos, $len, null, $suggestions);
            }

            $diff += (strlen($word) - $len);
        }

        $this->matches = $matches;
        return $matches;
    }
1272664
public function parse(string $text) : string
    {
        if ($text === '')
            throw new ParseException($this, $text, 0, self::NO_EMPTY);
        return $text;
    }
862704
public function extractMentions($text)
    {
        $matches = array();

        if (preg_match_all(ComPeopleDomainEntityPerson::PATTERN_MENTION, $text, $matches)) {
            return array_unique($matches[1]);
        } else {
            return array();
        }
    }
1198116
public function showMoreFilter($text)
    {
        // <!--more--></div>
        $text = str_replace('<!--more--></div>', '</div><!--more-->', $text);

        $text_array = explode('<!--more-->', $text, 2);

        if (2 === \count($text_array) && $text_array[0] && $text_array[1]) {
            $result = '<div class="show-more-block">';

            $result .= '<div class="show-more-teaser">' . $text_array[0] . '</div>';
            $result .= '<div class="show-more-complete">' . $text_array[1] . '</div>';
            $result .= '<div class="show-more-button"><span class="link">Подробнее...</span></div>';

            $result .= '</div>';

            return $result;
        }

        return $text;
    }
678297
public function find_formulas($text) {
        preg_match_all(self::FORMULAS_IN_TEXT_REGEX, $text, $matches);
        return array_combine($matches[1], $matches[1]);
    }
792331
public function parseText(String $text)
    {
        // Space after . and next word begin with uppercase
        $pieces = explode('.', $text);
        $new_pieces = [];
        foreach ($pieces as $piece) {
            array_push($new_pieces, ucfirst($piece));
        }
        $text = implode('. ', $new_pieces);

        // Space after ? and next word begin with uppercase
        $pieces = explode('?', $text);
        $new_pieces = [];
        foreach ($pieces as $piece) {
            array_push($new_pieces, ucfirst($piece));
        }
        $text = implode('? ', $new_pieces);

        // Space after ,
        $pieces = explode(',', $text);
        $text = implode(', ', $pieces);

        return $text;
    }
276128
public function readTab($text) {
		$pieces = explode("\n", $text);
		$result = [];
		foreach ($pieces as $piece) {
			$tmp = explode("\t", trim($piece, "\r\n"));
			$result[] = $tmp;
		}
		return $result;
	}
488820
private function parseLinks($text)
    {
        $offset = 0;
        $matches = array();
        // Extract all links from the text of the passage (if they exist)
        while (preg_match($this->links_pattern, $text, $matches, 0, $offset)) {
            switch ($matches[2]) {
                case '->':
                    $this->links[] = array('text' => trim($matches[1]), 'link' => trim($matches[3]));
                    $this->raw_links[] = $matches[0];
                    break;
                case '<-':
                case '|':
                    $this->links[] = array('text' => trim($matches[3]), 'link' => trim($matches[1]));
                    $this->raw_links[] = $matches[0];
                    break;
                default:
                    throw new \RuntimeException("Something that looked like a link could not be parsed.");
            }
            $offset = mb_stripos($text, $matches[0]) + mb_strlen($matches[0]);
        }
    }
877601
public function parse(string $text) : array
    {
        $index = 0;
        $items = Text::split($text, $this->separator);
        $array = [];
        try {
            foreach ($items as $item) {
                $array[] = $this->syntax->parse($item);
                $index += strlen($item) + 1;
            }
        } catch (ParseException $e) {
            $extra = [
                'type' => 'invalid-item',
                'item' => $item,
                'position' => $e->position()
            ];
            throw new ParseException($this, $text, $index + $e->position(),
                "Unable to parse the item '{$item}'", $extra, $e
            );
        }

        return $array;
    }
1310217
private function getTranslatedText($text)
    {
        if ($this->isEnglish($text)) {
            return $text;
        }
        $text = $this->removeSegment($text);
        $url = $this->getTranslateUrl($text);
        $response = $this->http->get($url);

        return $this->getTranslation(json_decode($response->getBody(), true));
    }