problem pattern matching a url with question mark
| From: | sgibbs at vt dot globalhealth dot org | Date: | Tue, 23 Oct 2001 17:35:55 +0000 |
| Subject: | problem pattern matching a url with question mark | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-71969@lists.php.net to get a copy of this message | ||
I found the following code currently used on our website to match a url
expression. Unfortunately, when I added a question mark, the webpage that
contained the url with the question mark just "hung" and would not load into
my browser at all. Currently, the url links only up to the question mark.
Here's the url I'm trying to get to work:
http://www.thejakartapost.com/yesterdaydetail.asp?fileid=20011018.G07
Can you look at the code below and tell me what I'm doing wrong?
- Shawna
ORIGINAL CODE
// this will find web addresses and encapsulate each one in a standard
anchor
while(ereg("http://([\/~_\.0-9A-Za-z#&-]+)", $content,
$match)){
$http_old = $match[0];
$http = "dubdubdub" . $match[1] . $match[2];
$url = "<A
HREF=\"javascript:externalURL('$http')\";>$http</A>";
$content = ereg_replace($http_old, $url, $content);
};
$content = ereg_replace("dubdubdub", "http://",
$content);
CODE WITH QUESTION MARK
// this will find web addresses and encapsulate each one in a standard
anchor
while(ereg("http://([\/~_\.0-9A-Za-z#&-?]+)", $content,
$match)){
$http_old = $match[0];
$http = "dubdubdub" . $match[1] . $match[2];
$url = "<A
HREF=\"javascript:externalURL('$http')\";>$http</A>";
$content = ereg_replace($http_old, $url, $content);
};
$content = ereg_replace("dubdubdub", "http://",
$content);