Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为什么我的正则表达式不起作用?_Html_Regex - Fatal编程技术网

Html 为什么我的正则表达式不起作用?

Html 为什么我的正则表达式不起作用?,html,regex,Html,Regex,我试图从html页面中提取标题,我使用正则表达式获取标题,如下所示: 正则表达式: <h6 class="panel-title"><i class="icon-file-music2"><\/i>(.*?)<i class=" icon-info3 text-success" data-popup="tooltip" data-html="true" title="(.*)" data-placement="bottom"><\/i>

我试图从html页面中提取标题,我使用正则表达式获取标题,如下所示:

正则表达式:

<h6 class="panel-title"><i class="icon-file-music2"><\/i>(.*?)<i class=" icon-info3 text-success" data-popup="tooltip" data-html="true" title="(.*)" data-placement="bottom"><\/i>\n<\/h6>
(.*)\n
要分析的代码:

<div class="panel-heading">
                                    <h6 class="panel-title"><i class="icon-file-music2"></i> TRXD - Sometimes.mp3
<i class=" icon-info3 text-success" data-popup="tooltip" data-html="true" title="<b>Uploaded on:</b><br/> 2017-11-14 06:56:54<br>  <b>Downloads:</b><br/> 7" data-placement="bottom"></i>

</h6>
                                    </div>

TRXD-times.mp3


我想要回复的部分是
TRXD-times.mp3
。我使用的正则表达式似乎不起作用,如果有人能解释我做错了什么,我将不胜感激。

这里有一个有效的例子:,您缺少新行捕获。

-不要使用正则表达式解析HTML。正则表达式是错误的工具-使用将加载DOM的工具,然后从中开始。您需要启用单行修饰符
s
,并在末尾添加第二行换行符:
\n\n
@Rawing请转换为答案。谢谢这个问题对未来的读者不会有用。与其回答它,我宁愿把它作为一个拼写错误/没有帮助的关闭。