@param string $text

@return ParsedShortcode[]
977451
public function parse($text)
    {
        $names = $this->names
            ? implode('|', array_map('preg_quote', $this->names))
            : RegexBuilderUtility::buildNameRegex();
        $regex = str_replace('<NAMES>', $names, static::$shortcodeRegex);
        preg_match_all($regex, $text, $matches, PREG_OFFSET_CAPTURE);

        $shortcodes = array();
        $count = count($matches[0]);
        for($i = 0; $i < $count; $i++) {
            $name = $matches[2][$i][0];
            $parameters = static::parseParameters($matches[3][$i][0]);
            $content = $matches[5][$i][1] !== -1 ? $matches[5][$i][0] : null;
            $match = $matches[0][$i][0];
            $offset = mb_strlen(substr($text, 0, $matches[0][$i][1]), 'utf-8');

            $shortcode = new Shortcode($name, $parameters, $content, null);
            $shortcodes[] = new ParsedShortcode($shortcode, $match, $offset);
        }

        return $shortcodes;
    }
1142280
private function getSearchWords($text)
    {
        $result = [];
        if (is_string($text)) {
            $text = trim(preg_replace('/[\W_]+/u', ' ', $text));
            if ($text !== '') {
                $words = explode(' ', mb_strtolower($text));
                $words = array_values(array_unique($words));
                $duplicates = [];
                for ($i = 0; $i < count($words); ++$i) {
                    for ($j = 0; $j < count($words); ++$j) {
                        if ($i !== $j && @mb_stripos($words[$i], $words[$j]) === 0) {
                            $duplicates[] = $words[$j];
                        }
                    }
                }
                if (!empty($duplicates)) {
                    $words = array_values(array_diff($words, $duplicates));
                }
                $result = $words;
            }
        }

        return $result;
    }
449875
public function parse(string $text) : string
    {
        $tokens = $this->tokenizer->tokenize($text);
        $segments = $this->createSegments($tokens);
        $nodes = $this->createTree($segments);
        return $this->generator->generateMarkup($nodes);
    }
902303
static function parse_text($text)
    {
        $text = trim($text);
        $result = array();
        $lines = explode(self::$row_sep, $text);
        foreach ($lines as $line)
        {
            $result[] = self::parse_line($line);
        }
        return $result;
    }
1030527
public static function parse($text, $context = null)
    {
        if (!static::$_enabled || strpos($text, '{') === false) {
            return $text;
        }

        if ($context === null) {
            $context = static::_getDefaultContext();
        }

        static::cache('context', $context);
        $pattern = static::_regex();

        return preg_replace_callback("/{$pattern}/s", 'static::_doShortcode', $text);
    }
678297
public function find_formulas($text) {
        preg_match_all(self::FORMULAS_IN_TEXT_REGEX, $text, $matches);
        return array_combine($matches[1], $matches[1]);
    }
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]);
        }
    }
893828
protected function _processText($text)
    {
        $matches = array();

        preg_match_all("/(href|src)=\"(?!http|ftp|https|mailto|data)([^\"]*)\"/", $text, $matches, PREG_SET_ORDER);

        foreach ($matches as $match)
        {
            $route = $this->getObject('lib:dispatcher.router.route', array(
                'url'    => $match[2],
                'escape' => false
            ));

            //Add the host and the schema
            $route->scheme = $this->getUrl()->scheme;
            $route->host   = $this->getUrl()->host;

            $text = str_replace($match[0], $match[1].'="'.$route.'"', $text);
        }

        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;
	}
559172
protected function getMatches($text)
    {
        $matches = [];
        if (!$found = preg_match_all($this->buildRegex(), $text, $matches)) {
            return [];
        }

        return $matches[0];
    }
445928
public function extractHashtagTerms($text)
    {
        $matches = array();

        if (preg_match_all(ComHashtagsDomainEntityHashtag::PATTERN_HASHTAG, $text, $matches)) {
            return array_unique($matches[1]);
        } else {
            return array();
        }
    }
241589
public static function parseInlineOperator($text)
    {
        $operator_name = 'contains';
        $operator = Arr::get($text, 0, '');
        $value = Arr::get($text, 1, false);

        self::checkInlineOperator($operator, $value);

        if (!empty($operator)) {
            $operator_name = Arr::get(self::getOperator('string', $operator), 'inline', 'contains');
        }

        return [
            $operator_name,
            $operator,
            $value,
        ];
    }
56441
protected function doFencedCodeBlocks($text) {
	
		$less_than_tab = $this->tab_width;
		
		$text = preg_replace_callback('{
				(?:\n|\A)
				# 1: Opening marker
				(
					(?:~{3,}|`{3,}) # 3 or more tildes/backticks.
				)
				[ ]*
				(?:
					\.?([-_:a-zA-Z0-9]+) # 2: standalone class name
				)?
				[ ]*
				(?:
					' . $this->id_class_attr_catch_re . ' # 3: Extra attributes
				)?
				[ ]* \n # Whitespace and newline following marker.
				
				# 4: Content
				(
					(?>
						(?!\1 [ ]* \n)	# Not a closing marker.
						.*\n+
					)+
				)
				
				# Closing marker.
				\1 [ ]* (?= \n )
			}xm',
			array($this, '_doFencedCodeBlocks_callback'), $text);

		return $text;
	}
932423
private function parseTxt($txt)
    {
        $result = [];
        $lines = array_map('trim', mb_split('\r\n|\n|\r', $txt));
        // Parse each line individually
        foreach ($lines as $key => $line) {
            // Limit rule length
            $line = mb_substr($line, 0, self::MAX_LENGTH_RULE);
            // Remove comments
            $line = explode('#', $line, 2)[0];
            // Parse line
            $result[] = $this->parseLine($line);
            unset($lines[$key]);
        }
        return in_array(true, $result, true);
    }
1223015
private function parseInlineHtml($text)
	{
		if (strpos($text, '>') !== false) {
			// convert a name markers to \labels
			if (preg_match('~^<((a|span)) (name|id)="(.*?)">.*?</\1>~i', $text, $matches)) {
				return [
					['label', 'name' => str_replace('#', '::', $this->labelPrefix . $matches[4])],
					strlen($matches[0])
				];
			}
		}
		return [['text', '<'], 1];
	}
265025
private function decodeContentTypesFromText($text)
    {
        $contenttypes = [];

        if ((substr($text, 0, 1) == '(') &&
            (substr($text, -1) == ')')
        ) {
            $contenttypes = explode(',', substr($text, 1, -1));
        } else {
            $contenttypes[] = $text;
        }

        $instance = $this;
        $contenttypes = array_map(
            function ($name) use ($instance) {
                $ct = $instance->getContentType($name);

                return $ct['slug'];
            },
            $contenttypes
        );

        return $contenttypes;
    }
368428
public function processText($text)
    {
        if ((string) $text != '') {
            $store = array();
            $_store = 0;
            $_offset = 0;
            if ($this->parser->strip) {
                if (strpos($text, '<') !== false) {
                    // capture html elements not to be messed with
                    $_offset = 0;
                    if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
                                       $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
                        foreach ($matches as $match) {
                            $store[] = $match[ 0 ][ 0 ];
                            $_length = strlen($match[ 0 ][ 0 ]);
                            $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
                            $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);

                            $_offset += $_length - strlen($replace);
                            $_store ++;
                        }
                    }

                    $expressions = array(// replace multiple spaces between tags by a single space
                                         // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
                                         '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s'                                    => '\1 \2',
                                         // remove spaces between attributes (but not in attribute values!)
                                         '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
                                         '#^\s+<#Ss'                                                               => '<',
                                         '#>\s+$#Ss'                                                               => '>',
                                         $this->stripRegEx                                                         => '');

                    $text = preg_replace(array_keys($expressions), array_values($expressions), $text);
                    $_offset = 0;
                    if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches,
                                       PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
                        foreach ($matches as $match) {
                            $_length = strlen($match[ 0 ][ 0 ]);
                            $replace = $store[ $match[ 1 ][ 0 ] ];
                            $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);

                            $_offset += strlen($replace) - $_length;
                            $_store ++;
                        }
                    }
                } else {
                    $text = preg_replace($this->stripRegEx, '', $text);
                }
            }
            return new Smarty_Internal_ParseTree_Text($text);
        }
        return null;
    }