正则表达式的问题。 我想匹配<span class="link_title"><a href="/tianlesoftware/article/details/6704642" title="[置顶]再谈学习方法">[置顶]再谈学习方法</a></span> 中的后面的“[置顶]再谈学习方法”,没学过正则,求帮助,谢谢了~~~~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $str='<span class="link_title"><a href="/tianlesoftware/article/details/6704642" title="[置顶]再谈学习方法">[置顶]再谈学习方法</a></span> ';preg_match('#title="(.*?)"#i',$str,$arr);echo $arr[1]; 你这个在光这个字符串确实可以用,但是在对于整个网页就用不了了,你能file_get_contents("http://blog.csdn.net/tianlesoftware/article/details/6704642")作为字符串再修改一下吗,谢谢了~~~~; 你要说清楚啊。我的代码是基于你贴出的字符串啊。。那个页面很多title。你要指明想要哪里的title 我结合你的正则解决了,谢谢function getTitle($content){ //preg_match('/<title>(.+?)<\/title>/iU',$content,$matchs); $preg="/<span class=\"link_title\"><a href=\"(.*)\" title=\"(.*)\>(.*)<\/a><\/span>/iU"; preg_match($preg,$content,$matchs); $content2=$matchs[1]; $preg2="#title=\"(.*?)\"#i"; preg_match($preg,$content,$matchs2); return $matchs2[3]; } Fatal error: Out of memory (allocated 262144) (tried to allocate 10267220 bytes) xampp PHP的file_put_contents为什么只能输出ANSI编码的TXT文件? 关于checkbox的问题 按钮作链接怎么做打开新窗口? phpMyAdmin的权限设置 问一个文件上传的问题 引号的用法? MFC问题请教 如何分开读取数据库中用逗号分割的内容 请教一个PHP最简单的问题 求帮助 数组 合并 方法
preg_match('#title="(.*?)"#i',$str,$arr);
echo $arr[1];
function getTitle($content){
//preg_match('/<title>(.+?)<\/title>/iU',$content,$matchs);
$preg="/<span class=\"link_title\"><a href=\"(.*)\" title=\"(.*)\>(.*)<\/a><\/span>/iU"; preg_match($preg,$content,$matchs);
$content2=$matchs[1];
$preg2="#title=\"(.*?)\"#i";
preg_match($preg,$content,$matchs2);
return $matchs2[3];
}