$re = '/([^"])((https?|s?ftp|ftps?|file)://.*?)([\s]|\"\s)/i';
$str = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- This file was created with the aha Ansi HTML Adapter. http://ziz.delphigl.com/tool_aha.php -->
<html xmlns="http://www.w3.org/1999/xhtml">
testssl.sh 2.7dev from https://testssl.sh/dev/
<span style="font-weight:bold;"> OCSP URI </span>http://clients1.google.com/ocsp
<span style="font-weight:bold;"> HTTP Status Code </span> 302 Found, redirecting to "https://www.google.nl/?gfe_rd=cr&ei=ZWjmV86hE5LH8AeFmaP4Bg"
';
$subst = "$1<a href=\"$2\">$2</a>$4";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php