[問題] PHP抓原始碼內容

看板RegExp (正規表示式 Regular Expression)作者 (None)時間13年前 (2011/08/04 11:41), 編輯推噓0(006)
留言6則, 3人參與, 最新討論串1/2 (看更多)
http://www.epinions.com/review/Canon_PowerShot_SX210_IS_Digital_Camera/content_536777166468 想從上面網址抓中間Review部分 Review是在本文位置 <span class=rkr> 本文 <br> 表達式這樣寫<span class=rkr>\s(.*)\s<br> 完全抓不到東西 然後\s(.*)\s<br>這樣抓到文章九成 剩下這段抓不到 Straight photography (Street, documentary, and environmental portraiture) is primarily concerned with capturing images of people in uncontrived, naturally lit and candid settings that evocatively depict or dramatically reveal some aspect of the human condition. In addition to being a first rate general purpose digicam, the nifty little SX210 is almost perfect for “straight” photography - it is compact, responsive, unobtrusive, features a 14x zoom (for a little extra standoff room) and dependably generates first rate images. 明明就有寫換行為什麼會抓不到在同一行的這一段 然後第一個和第二個的差別只差<span class=rkr> 然後就全沒了????? 好苦惱啊 希望有人能解答 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.137.134.31

08/04 11:53, , 1F
/<span class=rkr>(.*?)<b>Recommended:/s
08/04 11:53, 1F

08/04 11:56, , 2F
從<span class=rkr>到文字中間有不只一個\n
08/04 11:56, 2F

08/04 11:56, , 3F
\s只能match到一個 你可以用\s*或是 加s modifier讓
08/04 11:56, 3F

08/04 11:56, , 4F
.包含\n
08/04 11:56, 4F

08/04 17:43, , 5F
用s modifier會從第一個<span class=rkr>開始抓的說
08/04 17:43, 5F

08/04 21:02, , 6F
<span class=rkr>\n +\n(.+<br>)$ 抓\1
08/04 21:02, 6F
文章代碼(AID): #1EEXJODP (RegExp)
討論串 (同標題文章)
文章代碼(AID): #1EEXJODP (RegExp)