日期:2014-05-17  浏览次数:20542 次

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

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

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

$string = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang="en" dir="ltr" class="client-nojs" xmlns="http://www.w3.org/1999/xhtml"><head><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" /></head><body>dsgfdg<br /></body><foot> <span style="color:red">dsgfdg</span></foot>';
$pattern = '/(<head.*>.*<\/head>)|(<foot.*>.*<\/foot>)/i';
print preg_replace($pattern, '', $string);