preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $string, $match);
$str = 'http://vvvk.com/video_ext.php?hash=14ec97238896a77f&hd=2"тест тест';
// вывод: http://vk.com/video_ext.php?oid=-77763225&id=456239976&hash=14ec97238896a77f&hd=2'тест
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var userName = getUrlVars()["username"];