$url="http://www.sohu.net/123.htm";
$content=file_get_contents("$url");
假设读取远程静态htm文件返回的是以下内容,存放在变量$content中,如何用正则表达式把“需要的部分”部分提取出来呢?
其他字符 <div id="content"> <div id="titlebottom"><script type="text/javascript" src="http://www.sohu.net/scripts/new/titlebottom.js"></script></div><br />
需要的部分</div> <div id="welcome">其他字符“需要的部分”前面的英文字符部分,做为一个整体的话,只在变量$content中出现一次,“需要的部分”后面的英文字符部分,做为一个整体的话,也只在变量$content中出现一次,正好把“需要的部分”包裹起来,我就想要中间那个部分。