我想从以下值
获得 2014年12月<tr>
<th rowspan="2" scope="row">Launch</th>
<td class="ttl"><a href=# onClick="helpW('h_year.htm');">Announced</a></td>
<td class="nfo">2014, December</td>
</tr>
我使用以下代码来取得成功
preg_match_all("/Announced<\/a><\/td><td class=\"nfo\">(.*?)<\/td>/m", $input_lines, $output_array);
我尝试 /./ s 代替 x ,但没有运气。我需要你的建议。
PS:我不能使用DOM解析器,因为我已经有很多模式可以根据我的需要使用正则表达式提取字符串。
编辑: 这现在也解决了我的问题
preg_match_all("/(Announced<\/a><\/td>).*?(<td class=\"nfo\">)(.*?)<\/td>/s", $input_lines, $output_array);
答案 0 :(得分:2)
您忘记在正则表达式中添加\n
字符。
preg_match_all("~Announced<\/a><\/td>\n<td class=\"nfo\">(.*?)<\/td>~m", $input_lines, $output_array);
^
|