regex - Automatic Linkification for network files in PHP -
i'm trying automatically detect links in user-submitted text , dynamically generate links. i've found works "normal" urls.
$pattern = "/(http|https|ftp|ftps)\:\/\/[a-za-z0-9\-\.]+\.[a-za-z]{2,3}(\/\s*)?/"; return preg_replace($pattern, "<a href=\"\\0\" rel=\"nofollow\" target=\"_blank\">\\0</a>", $str);
is there way expanded cover unc or mapped network drives such \\computername\sharedfolder\file.txt
or z:\dir\file.txt
?
i'm not looking perfect solution.
the obvious non perfect solution have 3 patterns , check each 1 in turn. (so, \\ , [a-z]:\ , grab first whitespace.)
Comments
Post a Comment