Re: [請益] preg_match_all的問題

看板PHP作者 (薛丁格的貓)時間18年前 (2007/12/28 09:59), 編輯推噓2(202)
留言4則, 4人參與, 最新討論串2/4 (看更多)
※ 引述《AMOUAMOU (AMOU)》之銘言: : E%B6%E5%A5%BD&fr2=tab-web : 而我想抓搜尋頁面裡面的各個連結和分頁連結 : 我發現到連結都是由 : <a href="http://tw.wrs.yahoo.com/_ylt=A8tUxyqKvHNHHy4AQQNw1gt./SIG= : 12f1n7o30/EXP=1198853642/**http%3A// : tw.news.yahoo.com/article/url/d/a/071128/1/ozs4.html" target=_blank> : 且當我在抓分頁連結的時候,嘗試了很多種判斷方法,都無法順利抓到,好像在判斷 : _底線的時候出了問題,我就算使用了[_]也沒辦法解決,我在這方面是新手,希望各位 : 大大可以指導我,非常感謝!! '/<a .*href=(["|\'])([^\\1]*?)\\1/im' 一行太短. 所以加點注解/ .* => 防止中間有什麼 class xx oo 的東西. (["|\']) 最好用[\"|\'] => 抓出是用 ' or " 作開頭... [^\\1]*? =>不是 開頭的 " or ' 所有字符 *? greek match \\1 結尾的 ' or " 如果 200% 確定 他們不會用 ' 當開頭那就 href="([^"]*)" 搞定收工 -- Exactly. For that one fraction of a second, you were open to options you had never considered. THAT is the exploration that awaits you: not mapping stars and studying nebulae,but charting the unknown possibilities of existence. Star Trek S7E26 "All Good Thing" -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.248.154.212 ※ 編輯: alpe 來自: 60.248.154.212 (12/28 10:01)

12/28 12:46, , 1F
好文 推一下
12/28 12:46, 1F

12/28 21:32, , 2F
謝謝指教^^
12/28 21:32, 2F

12/28 22:55, , 3F
挑錯字,貪婪應該是greed XD
12/28 22:55, 3F

12/31 11:26, , 4F
@@ greed greed 好樣的打成 希臘比對啦
12/31 11:26, 4F
文章代碼(AID): #17T5YM8T (PHP)
討論串 (同標題文章)
文章代碼(AID): #17T5YM8T (PHP)