public function makeLinks($text)
    {
        $pattern = '~(?xi)
              (?:
                ((ht|f)tps?://)                    # scheme://
                |                                  #   or
                www\d{0,3}\.                       # "www.", "www1.", "www2." ... "www999."
                |                                  #   or
                www\-                              # "www-"
                |                                  #   or
                [a-z0-9.\-]+\.[a-z]{2,4}(?=/)      # looks like domain name followed by a slash
              )
              (?:                                  # Zero or more:
                [^\s()<>]+                         # Run of non-space, non-()<>
                |                                  #   or
                \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
              )*
              (?:                                  # End with:
                \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
                |                                  #   or
                [^\s`!\-()\[\]{};:\'".,<>?«»“”‘’]  # not a space or one of these punct chars
              )
        ~';

        $callback = function ($urlMatch) {
            $url = $urlMatch[0];

            // Look for protocol
            preg_match('~^(ht|f)tps?://~', $url, $protocolMatch);

            if ($protocolMatch) {
                $protocol = $protocolMatch[0];
            } else {
                $protocol = 'http://';
                $url = $protocol.$url;
            }

            // Start building caption, remove protocol from url
            $noProtocol = substr($url, strlen($protocol));

            // Check for a variation of www
            preg_match('/www\d{0,3}\./', $noProtocol, $wwwMatch);

            if ($wwwMatch) {
                // Remove www
                $noProtocol = substr($noProtocol, strlen($wwwMatch[0]));
            }

            // Only use domain name as caption
            $caption = explode('/', $noProtocol)[0];

            return $this->generateTag('a', $this->linkAttributes + ['href' => $url, $this->externalKey => $caption]);
        };

        return preg_replace_callback($pattern, $callback, $text);
    }
public function makeLinks($text)
    {
        $pattern = '~(?xi)
              (?:
                ((ht|f)tps?://)                    # scheme://
                |                                  #   or
                www\d{0,3}\.                       # "www.", "www1.", "www2." ... "www999."
                |                                  #   or
                www\-                              # "www-"
                |                                  #   or
                [a-z0-9.\-]+\.[a-z]{2,4}(?=/)      # looks like domain name followed by a slash
              )
              (?:                                  # Zero or more:
                [^\s()<>]+                         # Run of non-space, non-()<>
                |                                  #   or
                \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
              )*
              (?:                                  # End with:
                \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
                |                                  #   or
                [^\s`!\-()\[\]{};:\'".,<>?«»“”‘’]  # not a space or one of these punct chars
              )
        ~';

        $callback = function ($urlMatch) {
            $url = $urlMatch[0];

            // Look for protocol
            preg_match('~^(ht|f)tps?://~', $url, $protocolMatch);

            if ($protocolMatch) {
                $protocol = $protocolMatch[0];
            } else {
                $protocol = 'http://';
                $url = $protocol.$url;
            }

            // Start building caption, remove protocol from url
            $noProtocol = substr($url, strlen($protocol));

            // Check for a variation of www
            preg_match('/www\d{0,3}\./', $noProtocol, $wwwMatch);

            if ($wwwMatch) {
                // Remove www
                $noProtocol = substr($noProtocol, strlen($wwwMatch[0]));
            }

            // Only use domain name as caption
            $caption = explode('/', $noProtocol)[0];

            return $this->generateTag('a', $this->linkAttributes + ['href' => $url, $this->externalKey => $caption]);
        };

        return preg_replace_callback($pattern, $callback, $text);
    }
public function makeLinks ( $ text ) { $ pattern = '~(?xi)
              (?:
                ((ht|f)tps?://)                    # scheme://
                |                                  #   or
                www\d{0,3}\.                       # "www.", "www1.", "www2." ... "www999."
                |                                  #   or
                www\-                              # "www-"
                |                                  #   or
                [a-z0-9.\-]+\.[a-z]{2,4}(?=/)      # looks like domain name followed by a slash
              )
              (?:                                  # Zero or more:
                [^\s()<>]+                         # Run of non-space, non-()<>
                |                                  #   or
                \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
              )*
              (?:                                  # End with:
                \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
                |                                  #   or
                [^\s`!\-()\[\]{};:\'".,<>?«»“”‘’]  # not a space or one of these punct chars
              )
        ~' ; $ callback = function ( $ urlMatch ) { $ url = $ urlMatch [ 0 ] ; // Look for protocol preg_match ( '~^(ht|f)tps?://~' , $ url , $ protocolMatch ) ; if ( $ protocolMatch ) { $ protocol = $ protocolMatch [ 0 ] ; } else { $ protocol = 'http://' ; $ url = $ protocol . $ url ; } // Start building caption, remove protocol from url $ noProtocol = substr ( $ url , strlen ( $ protocol ) ) ; // Check for a variation of www preg_match ( '/www\d{0,3}\./' , $ noProtocol , $ wwwMatch ) ; if ( $ wwwMatch ) { // Remove www $ noProtocol = substr ( $ noProtocol , strlen ( $ wwwMatch [ 0 ] ) ) ; } // Only use domain name as caption $ caption = explode ( '/' , $ noProtocol ) [ 0 ] ; return $ this -> generateTag ( 'a' , $ this -> linkAttributes + [ 'href' => $ url , $ this -> externalKey => $ caption ] ) ; } ; return preg_replace_callback ( $ pattern , $ callback , $ text ) ; }
Make the links clickable.

@param $text

@return string
Make the links clickable .