A: 

It would be nice to see a sample of the code you were trying to use in PHP, but try the following (remember to change $_SERVER["HTTP_REFERER"] to your input variable):

if (preg_match('#http://(?:(?:(?:(?:[0-9a-z]|[0-9a-z](?:[\\x2d0-9a-z]?)*[0-9a-z])\\x2e)?)*(?:[a-z]|[a-z](?:[\\x2d0-9a-z]?)*[0-9a-z])|\\d+\\x2e\\d+\\x2e\\d+\\x2e\\d+)(?::\\d+)?(?:/(?:(?:[!\\x24\'-\\x2e0-9_a-z]|%[0-9a-f][0-9a-f]|[&:;=@])?)*(?:(?:/(?:(?:[!\\x24\'-\\x2e0-9_a-z]|%[0-9a-f][0-9a-f]|[&:;=@])?)*)?)*(?:\\x3f(?:(?:[!\\x24\'-\\x2e0-9_a-z]|%[0-9a-f][0-9a-f]|[&:;=@])?)*)?)?#i', $_SERVER["HTTP_REFERER"], $l_Results)) {
    $result = $l_Results[1];
} else {
    $result = "";
}
Templar
Unfortunately, this produces no result with $_SERVER["HTTP_REFERER"] equal to 'http://us2.php.net/'.
Alex R
I wouldn't expect it to - your regex requires http:// at the beginning. Perhaps you could explain better what you are trying to achieve.
Templar
test of autolinking in comments; i have the http written this time: http://us2.php.net/
Alex R
Yeah, stackoverflow removed the 'http://'; I had it in the original.
Alex R
Are you simply trying to identify a URI link inside of your input text? If so, your regex is incorrect and you should be using: \b(https?|ftp|file)://[-A-Z0-9+
Templar