I have this regex code:用於將文本鏈接轉換爲<a href=""> tags breaks in a certain use case
$hike_description = nl2br($hike_description);
//$hike_description = str_replace(array('\n','\r'),'',$hike_description);
//Convert all urls to links
$hike_description = preg_replace('#([\s|^])(www)#i', '$1http://$2', $hike_description);
$pattern = '#((http|https|ftp|telnet|news|gopher|file|wais):\/\/[^\s]+)#i';
$replacement = '<a href="$1" target="_blank">$1</a>';
$hike_description = preg_replace($pattern, $replacement, $hike_description);
It has worked 100% of the time....until now.
In this page the code didn't work for the first time. Specifically, it didn't place the " at the end of the link so the link kept going down the rest of the page:
http://www.comehike.com/hikes/scheduled_hike.php?hike_id=209的正則表達式
您會看到從頁面中間的鏈接一直延伸到底部並且未關閉嗎?
任何線索爲什麼這次可能發生,而不是任何其他時間?
謝謝!
PS - 這是在頁面上最終的HTML:
<a href="http://maps.google.com/maps?um=1&ie=UTF-8&q=little+river+canyon+center&fb=1&gl=us&hq=little+river+canyon+center&hnear=0x888a614b2e7272e5%3A0x913a5fafeec714d6%2CCentre%2C+AL&ei=GBsFTtedF8vUgAfex6zNAQ&sa=X&oi=local_group&ct=image&ved=0CAQQtgM<br" target="_blank">http://maps.google.com/maps?um=1&ie=UTF-8&q=little+river+canyon+center&fb=1&gl=us&hq=little+river+canyon+center&hnear=0x888a614b2e7272e5%3A0x913a5fafeec714d6%2CCentre%2C+AL&ei=GBsFTtedF8vUgAfex6zNAQ&sa=X&oi=local_group&ct=image&ved=0CAQQtgM<br</a> />
我加入HTML開始結束到我的問題的底部,但它也打破了這個問題:))))))它出現的方式不是我如何粘貼它! – Genadinik
我們可以看到輸入,而不是輸出 - 你已經告訴我們,已經連接了你的網頁 – tobyodavies
是的,我們需要在你做任何PHP處理之前看到URL –