首頁  >  文章  >  後端開發  >  正则不会 求解决解决办法

正则不会 求解决解决办法

WBOY
WBOY原創
2016-06-13 13:36:50666瀏覽

正则不会 求解决
怎么用正则删除网页的head 和 foot部分
页面是生成的  

或者有其他方法 删除网页的head 和 foot部分 请赐教

------解决方案--------------------
删除掉

以外的部分?
来个范例.
------解决方案--------------------
若是这样:你可以试一下:
PHP code

$string = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta content="正则不会 求解决 PHP 基础编程" name="Keywords"><meta content="怎么用正则删除网页 head 和 foot部分 页面是生成 或者有其他方法 删除网页 head 和 foot部分 请赐教" name="description"><title>正则不会  求解决 - PHP / 基础编程</title><link href="http://c.csdn.net/bbs/t/5/t5.css" rel="stylesheet" type="text/css">dsgfdg<br><foot> <span style="color:red">dsgfdg</span></foot>';
$pattern = '/(<head.>.*)|(<foot.>.*)/i';
print preg_replace($pattern, '', $string); <div class="clear">
                 
              
              
        
            </div></foot.></head.>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn