@param string $text
@param string $tag

@return string[]
325475
public function splitTag(string $text, string $tag): array
    {
        if (!$tag) {
            return [$text];
        }

        return preg_split('/(?=<'.$tag.'([^>])*>)/', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) ?: [$text];
    }
673790
private function findTokensForTag(string $tagName): array
    {
        $allTags = $this->getAllTags();

        return array_filter($allTags, function (array $tag) use ($tagName): bool {
            return substr($tag['content'], 1) === $tagName;
        });
    }
908599
public function tagged($tag)
    {
        if (! isset($this->tags[$tag])) {
            return [];
        }

        return new RewindableGenerator(function () use ($tag) {
            foreach ($this->tags[$tag] as $abstract) {
                yield $this->make($abstract);
            }
        }, count($this->tags[$tag]));
    }
524068
protected function _replaceTags(&$text)
    {
        if (!empty($this->_stripped_tags)) {
            $text = str_replace($this->_stripped_tags[0], $this->_stripped_tags[1], $text);
        }
    }
891576
protected function findIdentifiersByTagIncludingExpired($tag): array
    {
        $base = (new DateTimeService())->getCurrentTime();
        $GLOBALS['EXEC_TIME'] = 0;
        $identifiers = $this->findIdentifiersByTag($tag);
        $GLOBALS['EXEC_TIME'] = $base;

        return $identifiers;
    }
861902
public function taggedWith($tag)
    {
        $results = [];

        if (isset($this->tags[$tag]))
        {
            foreach ($this->tags[$tag] as $view)
            {
                $results[] = $view;
            }

        }

        return $results;
    }
241504
public static function statusNames(string $tag): array
    {
        $status_names = [];
        foreach (self::statusCodes($tag) as $status_code) {
            $status_names[$status_code] = self::statusName($status_code);
        }
        uasort($status_names, '\Fisharebest\Webtrees\I18N::strcasecmp');

        return $status_names;
    }
924257
private function convertToTagDoc(TagDoc $tag) : array
    {
        $tagArray = ['name' => $tag->getName()];

        $tagArray = $this->appendIfValueNotNull('description', $tag->getDescription(), $tagArray);

        return $tagArray;
    }
1181024
public function tagged($tag)
    {
        $results = [];

        if (isset($this->tags[$tag])) {
            foreach ($this->tags[$tag] as $abstract) {
                $results[] = $this->make($abstract);
            }
        }

        return $results;
    }
1029750
public function reverseTransform($texts)
    {
        // die(var_dump($texts));
        if (!$texts) {
            return null;
        }
        $tags = array();
        foreach ($texts as $text) {
            $tag = $this->tag_service->getTagByText($text);
            if (null === $tag) {
                $tag = $this->tag_service->saveTag($text);
            }
            $tags[] = $tag;
        }

        return $tags;
    }
1030952
private function getRanges(string $text, string $regex): array
	{
		preg_match_all($regex, $text, $matches, PREG_OFFSET_CAPTURE);

		$ranges = array_map(function ($match) {
			return [$match[1], strlen($match[0])];
		}, $matches[0]);

		return $ranges;
	}
750135
public function getReleaseByTagName(string $tag): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/releases/tags/:tag',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $tag));
    }
861072
public static function parse(Tag &$Tag)
    {
        if (!empty($Tag->content) && $Tag->hasOption('translate') && is_callable(Config::get('translator'))) {
            $Tag->content = call_user_func_array(
                Config::get('translator'),
                array(
                    $Tag->content,
                    Config::get('textdomain')
                )
            );
        }
        
        if ($Tag->hasOption('bbContent')) {
            self::bb($Tag->content);
        }

        if ($Tag->hasOption('markdown')) {
            $Tag->addOption('cleanContent');
            self::markdown($Tag->content);
        }

        if ($Tag->hasOption('compress')) {
            self::compress($Tag);
        }

        return $Tag->content;
    }
1048896
public static function makeTagsArray($tags)
    {
        if (is_array($tags)) {
            $tags = array_unique(array_filter($tags));
        } else if (is_string($tags)) {
            $tags = preg_split('#[' . preg_quote(',', '#' ) . ']#', $tags, null, PREG_SPLIT_NO_EMPTY);
        } else {
            $tags = $tags->toArray();
        }

        $tagSet = [];
        foreach ($tags as $tag)
            $tagSet[] = Tag::taggify($tag);

        return $tagSet;
    }
1055876
public static function em($text, $htmlOptions = array(), $tag = 'p')
    {
        $color = TbArray::popValue('color', $htmlOptions);
        if (TbArray::popValue('muted', $htmlOptions, false)) {
            self::addCssClass('muted', $htmlOptions);
        } else {
            if (!empty($color)) {
                self::addCssClass('text-' . $color, $htmlOptions);
            }
        }
        return self::tag($tag, $htmlOptions, $text);
    }
744877
protected function _parseModulesTags(&$text)
    {
        $replace = array();
        $matches = array();

        // <ktml:modules position="[position]"></ktml:modules>
        if(preg_match_all('#<ktml:modules\s+position="([^"]+)"(.*"[^"]*")?>(.*)</ktml:modules>#siU', $text, $matches))
        {
            $count = count($matches[1]);

            for($i = 0; $i < $count; $i++)
            {
                $position = $matches[1][$i];
                $attribs  = $this->parseAttributes( $matches[2][$i] );
                $modules  = &ComKoowaModuleHelper::getModules($position);

                if(isset($attribs['condition']))
                {
                    if($this->_countModules($attribs['condition']))
                    {
                        unset($attribs['condition']);
                        $replace[$i] = $this->_renderModules($modules, $attribs);
                    }
                }
                else  $replace[$i] = $this->_renderModules($modules, $attribs);

                if(!empty($replace[$i])) {
                    $replace[$i] = str_replace('<ktml:modules:content>', $replace[$i], $matches[3][$i]);
                }
            }

            $text = str_replace($matches[0], $replace, $text);
        }

        // <ktml:modules position="[position]">
        if(preg_match_all('#<ktml:modules\s+position="([^"]+)"(.*"[^"]*")?>#iU', $text, $matches))
        {
            $count = count($matches[1]);

            for($i = 0; $i < $count; $i++)
            {
                $position = $matches[1][$i];
                $attribs  = $this->parseAttributes( $matches[2][$i] );
                $modules  = &ComKoowaModuleHelper::getModules($position);

                if(isset($attribs['condition']))
                {
                    if($this->_countModules($attribs['condition']))
                    {
                        unset($attribs['condition']);
                        $replace[$i] = $this->_renderModules($modules, $attribs);
                    }
                }
                else  $replace[$i] = $this->_renderModules($modules, $attribs);
            }

            $text = str_replace($matches[0], $replace, $text);
        }
    }
731116
private function parseTagBlock(string $tags, Types\Context $context): array
    {
        $tags = $this->filterTagBlock($tags);
        if (!$tags) {
            return [];
        }

        $result = $this->splitTagBlockIntoTagLines($tags);
        foreach ($result as $key => $tagLine) {
            $result[$key] = $this->tagFactory->create(trim($tagLine), $context);
        }

        return $result;
    }