linkifyUrl($m[0][1], $this->trimUrl($m[0][0])); } protected function linkifyUrl($tagPos, $url) { if (!\preg_match('/^[^:]+:|^www\\./i', $url)) return; $endTag = $this->parser->addEndTag($this->config['tagName'], $tagPos + \strlen($url), 0); if ($url[3] === '.') $url = 'http://' . $url; $startTag = $this->parser->addStartTag($this->config['tagName'], $tagPos, 0, 1); $startTag->setAttribute($this->config['attrName'], $url); $startTag->pairWith($endTag); } protected function trimUrl($url) { return \preg_replace('#(?![-=/)])[\\s!-.:-@[-`{-~\\pP]+$#Du', '', $url); } }