【发布时间】:2015-07-06 09:26:03
【问题描述】:
我对正则表达式不太熟悉。我正在尝试获得底部描述的结果。这是我到目前为止所做的(注意$page 包含制表符):
$page = "<div class=\"title-container\">
<h1>Text here<span> /Sub-text/</span> </h1>
</div>";
// TITLE
preg_match_all ('/<h1>(.*)<\/h1>/U', $page, $out);
$hutitle = preg_replace("#<span>(.*)<\/span>\s#", "", $out[1][0]);
$entitle = preg_replace("'(.*)<span> /'", "", $out[1][0]);
我想得到这个:
$hutitle = "Text here";
$entitle = "Sub-text"; (Without html and "/")
【问题讨论】:
标签: php regex string preg-match-all