通过PHP的preg_match_all()匹配多行模式

时间:2019-09-05 12:49:27

标签: php regex

如何在此HTML代码中通过PHP preg_match_all()正则表达式模式匹配主题:

$re = '/<tr>\D*<h2>(.*?)<\/h2>\s*<\/td>/m';
$str = '<table border=0>
<tr>
<fdgfdgdfg_____>
<td>


<h2>subject</h2>





</td>

<tr>
<fdgfdgdfg__-*dfg/dfgd*-é"-*(\'-/(/-/__5___>
<td>


<h2>subject</h2>


 </td>';

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

 // Print the entire match result
 var_dump($matches);

我需要得到所有的伴侣

0 个答案:

没有答案