concrete/src/Utility/Service/Text.php
public function autolink($input, $newWindow = false, $defaultProtocol = 'http://')
    {
        $target = $newWindow ? ' target="_blank"' : '';
        $output = preg_replace_callback(
            '/(http:\/\/|https:\/\/|(www\.))(([^\s<]{4,80})[^\s<]*)/',
            function (array $matches) use ($target, $defaultProtocol) {
                $protocol = strpos($matches[1], ':') ? $matches[1] : $defaultProtocol;
                return "<a href=\"{$protocol}{$matches[2]}{$matches[3]}\"{$target} rel=\"nofollow\">{$matches[2]}{$matches[4]}</a>";
            },
            $input);

        return $output;
    }
public function autolink($input, $newWindow = false, $defaultProtocol = 'http://')
    {
        $target = $newWindow ? ' target="_blank"' : '';
        $output = preg_replace_callback(
            '/(http:\/\/|https:\/\/|(www\.))(([^\s<]{4,80})[^\s<]*)/',
            function (array $matches) use ($target, $defaultProtocol) {
                $protocol = strpos($matches[1], ':') ? $matches[1] : $defaultProtocol;
                return "<a href=\"{$protocol}{$matches[2]}{$matches[3]}\"{$target} rel=\"nofollow\">{$matches[2]}{$matches[4]}</a>";
            },
            $input);

        return $output;
    }
public function autolink ( $ input , $ newWindow = false , $ defaultProtocol = 'http://' ) { $ target = $ newWindow ? ' target="_blank"' : '' ; $ output = preg_replace_callback ( '/(http:\/\/|https:\/\/|(www\.))(([^\s<]{4,80})[^\s<]*)/' , function ( array $ matches ) use ( $ target , $ defaultProtocol ) { $ protocol = strpos ( $ matches [ 1 ] , ':' ) ? $ matches [ 1 ] : $ defaultProtocol ; return "<a href=\"{$protocol}{$matches[2]}{$matches[3]}\"{$target} rel=\"nofollow\">{$matches[2]}{$matches[4]}</a>" ; } , $ input ) ; return $ output ; }
Scans passed text and automatically hyperlinks any URL inside it.

@param string $input
@param bool $newWindow
@param string $defaultProtocol

@return string $output
Scans passed text and automatically hyperlinks any URL inside it .