如何将HTML转换为正则表达式

如何将HTML转换为正则表达式,html,regex,transform,Html,Regex,Transform,我将从href=“download.php?id=469979”中提取此“OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent” 谢谢PHP代码: <?php $re = '/(?<=">\s)(?:.*)(?=<)/m'; $str = '<a class="index" href="download.php?id=469979"><img src=

我将从href=“download.php?id=469979”中提取此“OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent”


谢谢

PHP代码:

<?php
$re = '/(?<=">\s)(?:.*)(?=<)/m';
$str = '<a class="index" href="download.php?id=469979"><img src="styles/images/download.png" style="position:relative;bottom:1px;" alt="Download" border="0"> OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent</a>
';

preg_match_all($re, $str, $matches);

// Print the entire match result
print_r($matches);
?>
/(?<=">\s)(?:.*)(?=<)/m
Array
(
    [0] => Array
        (
            [0] => OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent
        )

)

请参见:

现在说什么?你想做什么,为什么要这样做,你想取得什么样的结果?现在还不清楚你到底要求什么。“将html转换为正则表达式”是什么意思?正则表达式是一种搜索模式,html是标记代码。他们没有共同之处。你不能将它们“转换”成彼此。也许你想要与代码匹配的正则表达式?请解释。
*
将转换任何HTML、任何文本。。。。什么都行!我将从“href=“download.php?id=469979”中提取这个OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent,我将从href=“download.php?id=469979”中提取这个.torrent文件,它将提取没有标签的文本。
<?php
$re = '/(?<=">\s)(?:.*)(?=<)/m';
$str = '<a class="index" href="download.php?id=469979"><img src="styles/images/download.png" style="position:relative;bottom:1px;" alt="Download" border="0"> OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent</a>
';

preg_match_all($re, $str, $matches);

// Print the entire match result
print_r($matches);
?>
/(?<=">\s)(?:.*)(?=<)/m
Array
(
    [0] => Array
        (
            [0] => OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent
        )

)