php正则表达式如何匹配title?

2024年11月23日 01:11
有3个网友回答
网友(1):

php正则表达式匹配title的代码如下:

$file = "百度知道——提问问题";

preg_match_all('/(.*)<\/title>/i',$file,$content); </p> <p>echo '<pre>';</p> <p>print_r($content);</p> <p>结果:</p> <p><img loading="lazy" class="ikqb_img" src="/picurl?url=https%3A%2F%2Fiknow-pic.cdn.bcebos.com%2Fb64543a98226cffc743c05d4be014a90f603ea46%3Fx-bce-process%3Dimage%252Fresize%252Cm_lfit%252Cw_600%252Ch_800%252Climit_1%252Fquality%252Cq_85%252Fformat%252Cf_auto" esrc="https://iknow-pic.cdn.bcebos.com/b64543a98226cffc743c05d4be014a90f603ea46"></p></p> </div> </div> <div class="clear"></div> </div> <div class="wdhdnr"> <div class="huidanrtop"> <div class="wdhuidaxinx"> <div class="wdhuidaxm">网友(2):</div> </div> </div> <div class="clear"></div> <div class="wdhuidanrmid"> <div class="zuijiacont"> <p><?php<br>$s = '<a title="abc.jpg" href="fefefe"><br> <img src="xsdsd.jpg" alt=\'xxsd.jpg\' title="eeerrfff" /><br> </a><br> <img src="xsdsd.jpg" alt="eeerrfff.pngxxsd" title="xxsd.jpg" />';<br>$pat = '/(<img.*?)((alt|title)=[\'"]+[^\'|"]*\.(jpg|gif|png|bmp)[\'"]+)/';<br>echo preg_replace($pat , '$1' , $s);<p><br></p> <p><br></p> <p></p></p> </div> </div> <div class="clear"></div> </div> <div class="wdhdnr"> <div class="huidanrtop"> <div class="wdhuidaxinx"> <div class="wdhuidaxm">网友(3):</div> </div> </div> <div class="clear"></div> <div class="wdhuidanrmid"> <div class="zuijiacont"> <p><p>$file = "<title>百度知道——提问问题";

preg_match_all('/(.*)<\/title>/i',$file,$content); </p> <p>echo '<pre>';</p> <p>print_r($content);</p> <p>结果:</p> <p><img loading="lazy" class="ikqb_img" src="/picurl?url=https%3A%2F%2Fiknow-pic.cdn.bcebos.com%2F5ab5c9ea15ce36d3deabff853ff33a87e850b1d3%3Fx-bce-process%3Dimage%252Fresize%252Cm_lfit%252Cw_600%252Ch_800%252Climit_1%252Fquality%252Cq_85%252Fformat%252Cf_auto" esrc="https://iknow-pic.cdn.bcebos.com/5ab5c9ea15ce36d3deabff853ff33a87e850b1d3"></p></p> </div> </div> <div class="clear"></div> </div> </div> </div> <div class="wendaright"> <div class="wdluluerwema"> <div class="wdxgwttop">相关问答</div> <div class="wdxgwtnr"> </div> <div class="clear"></div> </div> <!-- 其他随机问答['id'=>alphaID($like['zid'])] --> <div class="wdluluerwema"> <div class="wdxgwttop">最新问答</div> <div class="wdxgwtnr"> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/273325306.html">快乐大本营2011528谢娜的背景音乐有哪些</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/128428592.html">谁知道有没有SF冒险岛无限转生的</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/41564894.html">熵和焓有什么关系?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/337665163.html">开灶 吉日</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/1932251805520314107.html">天方夜谭又名什么是一部著名的什么民间故事</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/517586968.html">小花仙找王子,等级不限,但至少要有奇妙。王子要愿意帮我冲奇妙和QB、</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/86017957.html">八嘎呀路 日语怎么写</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/1818848174910640508.html">有什么好看的青春校园电影,要感人的同时又很叛逆的,能在优酷或爱奇艺搜得到的</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/270685913971985085.html">成人连续3天发烧应该怎么办</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://czqahb.com/article/2145230293685608108.html">我想问一下:在QQ上单方面的删除好友,对方的QQ上会不会有我的存在、</a></div> </div> </div> </div> </div> <div class="clear"></div> <div class="footer"> <!-- 移动底部导航 --> <div class="fanhuitop"><a href="#top" ref="nofollow"><img src="https://czqahb.com/static/old/img/fhtop.png" title="返回顶部"></a></div> <div class="dibu"> <div class="dibu"> </div> </div> <div class="banquan"> <p>内容全部来源于网络收集,如有侵权,请联系网站删除:QQ:24596024</p> </div> </div> </div> </div> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?0c9f72217b0fd07e33b2b148bdd4490c"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>