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

2024-11-23 01:11:29
推荐回答(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 class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/2118125781758640427.html" title="php正则表达式获取&lt;h1&gt;标题&lt;&#47;h1&gt;代码">php正则表达式获取&lt;h1&gt;标题&lt;&#47;h1&gt;代码</a></div> <div class="wdxgfbxinxi pcnone "></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/1964233264664975500.html" title="正则表达式匹配">正则表达式匹配</a></div> <div class="wdxgfbxinxi pcnone "></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/1833338261515376860.html" title="java正则表达式匹配">java正则表达式匹配</a></div> <div class="wdxgfbxinxi pcnone "></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/586749492918605445.html" title="正则表达式匹配的问题?">正则表达式匹配的问题?</a></div> <div class="wdxgfbxinxi pcnone "></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/622856480381735172.html" title="python 正则表达式为什么匹配不上">python 正则表达式为什么匹配不上</a></div> <div class="wdxgfbxinxi pcnone "></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/1388102900500428860.html" title="Python正则表达式如何排除某个匹配">Python正则表达式如何排除某个匹配</a></div> <div class="wdxgfbxinxi pcnone "></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/2208513574177190148.html" title="mysql正则表达式如何匹配GBK中文">mysql正则表达式如何匹配GBK中文</a></div> <div class="wdxgfbxinxi pcnone "></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/493520008128704692.html" title="如何匹配在PHP正则表达式一个井号符号">如何匹配在PHP正则表达式一个井号符号</a></div> <div class="wdxgfbxinxi pcnone "></div> </div> </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://aq8.net/392899900692813485.html">php正则表达式如何匹配title?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/377450716.html">商家与团购网站的合作流程是什么呢?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/213260494.html">小学生(10岁左右)啃手指如何解决?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/324206212.html">小明看一本80页的故事书,第一天看了全书的20%,第二天看了全书的25%,两天共看了</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/321357183.html">你好!哥哥!我想买一台笔记本不知道买什么牌子什么型号的!主要是用来绘图《CAD,UG》次要玩玩CF!上上网</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/441749279.html">笔记本R61i装win2003无线网卡驱动装不上</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/1886113820794339228.html">通达信的DDX数据不能显示了,怎么办</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/577755194.html">由3个a5个b2个c组成的字符串其中包含有子串‘abc’的有多少种?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/486926387.html">我有一盆无根的君子兰,请问怎么养保证它生根</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://aq8.net/141110336868030285.html">总是时不时的傻笑,哪怕是一个人的时候</a></div> </div> </div> </div> </div> <div class="clear"></div> <div class="footer"> <!-- 移动底部导航 --> <div class="fanhuitop"><a href="#top" ref="nofollow"><img src="https://aq8.net/static/old/img/fhtop.png" alt="返回顶部" 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?d86df1760ee607dc5bff1a7aab937e8e"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>