看板 PHP 關於我們 聯絡資訊
※ 引述《dinos (◤◢██◣◥█████)》之銘言: : ※ 引述《hfnadkv (衝衝衝)》之銘言: : : 現在有個小問題想請教一下 : : 就是我要處理一堆字串 : : 因為結構都不一致,也就是不能用出現的位置來取字串 : : 有規則可尋的只有<br><br><td>xxx</td> : : 字串內容如下 : : <td>1235565</td>....<br><br><td>computer</td> : : <td>45645</td>....<br><br><td>book</td> : : <td>789</td>....<br><br><td>network</td> : : 那該用什麼函數或方法將computer,book,network這些字取出來呢? : $str=preg_replace("/^<td.*<td>([a-zA-Z]+)<\/td>$/","\\1",$str); \w 跟 [a-zA-Z] 就差了一個 _ preg_macth('/<td>(\w+)<\/td>/si',$str,$match); $match[1] 就是你要的. -- Live Long and Prosper -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 221.169.25.33
superGA:RE達人 推一個 01/02 01:46