text->indexOf($str); if ($pos === false) { return; } preg_match_all($regexp, $this->text, $matches, PREG_OFFSET_CAPTURE, $pos); foreach ($matches[0] as [$match, $matchPos]) { $matchLen = strlen($match); $endPos = $matchPos + $matchLen - 2; $this->parser->addTagPair($tagName, $matchPos, 2, $endPos, 2); $this->text->overwrite($matchPos, 2); $this->text->overwrite($endPos, 2); } } }