看板 RegExp 關於我們 聯絡資訊
抱歉 小弟是regex 新手 我想做的是在一個html 檔案中 抓出<img src="http://xxx" 後面的http link 例如<img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSAld0OftpLbXdQf71QlwOtNzdG8bqEMVnPM2A2Uper5UYgxFgR zv6d2O9R" width=130 height=98 style="border:1px solid #ccc;padding:1px"> 這樣子的html plain text 要抓出那張圖片的link 可是我不知道怎麼做@@ 試了幾種語法 都會把後面的垃圾也全抓出來 像是pattern= "<img src=\"(.)+\"" 這樣子起始位置是會對 只是會抓到最後一個 " 而不會在一碰到" 就停下來@@ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.4.192
aqer1224:試試看 <img src=\"([^"]+)\" 06/13 15:27
singlovesong:OK了 謝謝!!:) 看來regex 還要多學學.. 06/13 15:47
PurpleCrow:"<img src=\"(.+?)\"" 如果你要用.的話 06/16 10:34