看板 PHP 關於我們 聯絡資訊
假如我要抓下面網頁中的藝術文化 導覽 活動 攝影...\等tag 請問用正規法要怎麼寫呢?? 我怎麼寫都錯誤@@""" <font class=mbody><a href="http://tw.dir.yahoo.com/Art/"><b>藝術文化</b></a> </font><br> <a href="http://tw.dir.yahoo.com/art/Guidelines/">導覽</a>,&nbsp;<a href= "http://tw.dir.yahoo.com/art/Activities/">活動</a>,&nbsp;<a href= "http://tw.dir.yahoo.com/art/classification/Photography/">攝影</a>, &nbsp;<a href="http://tw.dir.yahoo.com/art/classification/music/Singers/"> 歌手歌星</a><br> <a href="http://tw.dir.yahoo.com/art/Comments/">評論</a>,&nbsp;<a href="http: //tw.dir.yahoo.com/art/classification/Painting/">繪畫</a>,&nbsp;<a href="http: //tw.dir.yahoo.com/art/classification/design_arts/Construction/">建築</a>,&nbs p;<a href="http://tw.dir.yahoo.com/art/classification/Traditional_Art/">傳統藝 術</a> 以下是我寫的.... <? $str = file_get_contents("http://tw.dir.yahoo.com/"); preg_match("<a href="http://*">*</a>/s", $str, $matches); echo $matches[1]; ?> 可是這樣好像不太對@@a 有爬文了可是還是不知道怎麼寫... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.129.161.41
LPH66:'/<a href="http:\/\/*">*<\/a>/s' 05/17 21:21
LPH66:等等 上一行不太對 05/17 21:22
LPH66:'/<a href="http:\/\/.*">(.*)<\/a>/' 這樣好像有比較對 05/17 21:22
LPH66:我其實有點忘了s選項是什麼意思了... 05/17 21:23
rikarika:那是不是每次都要加上/ /s ? 因為我不加就不能用 05/17 22:21
rikarika:你下面那個可以用耶:) 不過只跑出一個@ @ 05/17 22:28
yanli2:ereg_replace( "<[^<]*>", "", $str) 05/17 22:41
rikarika:謝謝大家 可以用了:D 05/17 22:52