欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

正则有关问题求教

程序员文章站 2022-05-21 17:43:20
...
正则问题求教
我想把字符串中的title内容找出来,该怎么弄?下面code是我写得,但不行..
PHP code

[\s\S]*?/';
$str='aaabbbbbbccccccccc';
$result=array();
preg_match($regex,$str,$result);
print_r($result);
?>



------解决方案--------------------
$regex='/([\s\S]*?)/'; <br><font color="#e78608">------解决方案--------------------</font><br>$regex='/<title>.*?/'; <div class="clear"> <a href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2suaHRtbD90PTI=" target="_blank" rel="nofollow"><img onerror="this.src='/statics/superweb999/images/image_error.jpg'"src="/default/index/img?u=aHR0cHM6Ly9pbWcucGhwLmNuL3VwbG9hZC9jb3Vyc2UvMDAwLzAwMC8wNzEvNjIwYzYwNGY3NTI1MTk5NS5wbmc=" style="margin-top: 30px;" alt="正则有关问题求教" title="正则有关问题求教"></a><p style="float:right;font-size:13px;color:#999;"><span class="red">声明:</span>本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。</p> </div> <p class="article-relative-header">相关文章</p> <p class="article-relative-header">相关视频</p> <hr class="layui-clear"> <ul class="article-relative-ul"> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy00ODg4ODkuaHRtbA==" target="_blank" rel="nofollow">详解win10下PHP的安装配置(以php5.6为...</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy00ODg4MzUuaHRtbA==" target="_blank" rel="nofollow">php Swoole实现毫秒定时计划任务(详解)</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy00ODg4NTQuaHRtbA==" target="_blank" rel="nofollow">【DTM】PHP协程客户端v0.1 beta版本发...</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy0yOTg2MTkuaHRtbA==" target="_blank" rel="nofollow">PHP中类的理解和应用[一]_PHP教程</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy0yMjA2ODIuaHRtbA==" target="_blank" rel="nofollow"> 正则有关问题求教 </a> </li> </ul> <ul class="article-relative-ul"> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvMzMwNi5odG1s" target="_blank" title="<title>" rel="nofollow"><title></a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvMzY3MS5odG1s" target="_blank" title="JavaScript RegExp 对象" rel="nofollow">JavaScript RegExp 对象</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvMzc4OS5odG1s" target="_blank" title="JavaScript RegExp 对象" rel="nofollow">JavaScript RegExp 对象</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvNzQwMC5odG1s" target="_blank" title="C# 的 Regex 类" rel="nofollow">C# 的 Regex 类</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvNzQwMi5odG1s" target="_blank" title="C# 的 Regex 类的常用方法" rel="nofollow">C# 的 Regex 类的常用方法</a> </li> </ul>