RE: [PHP] problem pattern matching a url with question mark

From: Date: Wed, 24 Oct 2001 21:31:17 +0000
Subject: RE: [PHP] problem pattern matching a url with question mark
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72170@lists.php.net to get a copy of this message
http://([\/~_\.0-9A-Za-z#&-?]+) first you have to escape the ? with a backslash and second the - has to go at the end of the [] or else it thinks you mean any char between & and ? On Wed, 24 Oct 2001 16:27:34 -0400, sgibbs@vt.globalhealth.org wrote: >ah, sorry about the confusion. The url I provided is just an example >of a >url containing a question mark for which I'm trying to find a >pattern match >in my content text. > > >-----Original Message----- >From: Neil Freeman [mailto:neil.freeman@asa.co.uk] >Sent: Wednesday, October 24, 2001 4:16 AM >Cc: php-general@lists.php.net >Subject: Re: [PHP] problem pattern matching a url with question mark > > >Why does your URL contain .asp? > >sgibbs@vt.globalhealth.org wrote: > >> 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.G0 >>7 >> >> 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); >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >> For additional commands, e-mail: php-general-help@lists.php.net >> To contact the list administrators, e-mail: >php-list-admin@lists.php.net >> >> *************************************************************** >> This message was virus checked with: SAVI 3.50 >> last updated 23rd October 2001 >> *************************************************************** > >-- >-------------------------------- > Email: neil.freeman@asa.co.uk > neil_freeman@yahoo.com >-------------------------------- > > -- Mark, maggelet@mminternet.com on 10/24/2001

« previous php.general (#72170) next »