$re = '/(\b)(https?:\/\/)(www.)?[\w-]{2,}\.[a-zA-Z\-0-9]{1,}[\w\/\.\?\=\&\#\-\%\+]*(\b)/i';
$str = 'http://127.0.0.1/openserver/phpmyadmin/sql.php?db=projectx&table=messages&sql_query=SELECT+%2A+FROM+%60messages%60&message_to_show=%D0%97%D0%B0%D0%BF%D0%B8%D1%81%D1%8C+%D0%B1%D1%8B%D0%BB%D0%B0+%D1%83%D0%B4%D0%B0%D0%BB%D0%B5%D0%BD%D0%B0&goto=tbl_sql.php&token=81b4b5c88dae1706231d6cd2ab925edb&message=%D0%A3%D0%B4%D0%B0%D0%BB%D0%B5%D0%BD%D0%B0+1+%D1%81%D1%82%D1%80%D0%BE%D0%BA%D0%B0.+%28%D0%97%D0%B0%D0%BF%D1%80%D0%BE%D1%81+%D0%B7%D0%B0%D0%BD%D1%8F%D0%BB+0.1904+%D1%81%D0%B5%D0%BA.%29
sd fs ';
$subst = "";
$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