政府立案,24小時全年無休!公司家庭搬遷、合約簽訂有保證 提供您平價又專業的搬家服務. | 裝璜拆除,店面拆除,地板拆除,廢棄物清運 服務有保證,安全高效率,客戶口碑肯定 |
[php] PHP正則表達式 過濾html |
房東:張先生 發表時間:2012-10-24 |
$contents = preg_replace("/\s+/", " ", $contents); //過濾多餘回車 $contents=preg_replace("/<(\/?img.*?)>/si","",$contents); //過濾img標籤 $contents=preg_replace("/<(\/?font.*?)>/si","",$contents); //過濾font標籤 $contents=preg_replace("/<(head.*?)>(.*?)<(\/head.*?)>/si","",$contents); //過濾head標籤 $contents=preg_replace("/<(select.*?)>(.*?)<(\/select.*?)>/si","",$contents); //過濾select標籤 $contents=preg_replace("/<(strong.*?)>(.*?)<(\/strong.*?)>/si","",$contents); //過濾strong標籤 $contents=preg_replace("/<(label.*?)>(.*?)<(\/label.*?)>/si","",$contents); //過濾label標籤 $contents=preg_replace("/<(a.*?)>(.*?)<(\/a.*?)>/si","",$contents); //過濾a標籤 |
|
廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲 完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心! 廣利不動產-新板特區指名度最高、值得您信賴的好房仲 您的托付,廣利用心為您服務 |
1 樓住戶:jack 發表時間:2012-10-24 |
$str = "abc <我是誰 > ghi (正則表示式) fffjkl[你是誰] $pattern = "/<[^>^<]*>/";// 正則表示式格式用於比對 $replacement = ""; // 以此(空)字串來取代 (即刪除) $newStr = preg_replace($pattern, $replacement, $str); echo $newStr; ?> |
2 樓住戶:jeff 發表時間:2012-10-26 |
移除[ ] 主題 $str='[分享] 好租好賣最優值'; $str2='[問題] 誠心指教!'; $str3='[討論]地產會泡沫化?'; echo preg_replace('/\[[^\]]+\]/','',$str); echo preg_replace('/\[[^\]]+\]/','',$str2); echo preg_replace('/\[[^\]]+\]/','',$str3); ?> |
3 樓住戶:creakj 發表時間:2012-11-02 |
移除[] or () 後面文字 $str1 = '打工20歲(40p)回復 1# Soldie'; $str2 = '新竹加油站[30P]........回復 1# g' echo substr($str1, 0, strrpos($str1, ')') + 1); echo substr($str2, 0, strrpos($str2, ']') + 1); |
姓名: | |||
佈告內容: | |||
其他選項: | |||
|