Home  >  Article  >  Backend Development  >  字符串截取解决方案

字符串截取解决方案

WBOY
WBOYOriginal
2016-06-13 12:40:30923browse

字符串截取

$subject = '<div class="superStar" id="test_0"><br />
 				you dead!<br />
				<div class="show">hello</div><br />
				<span>james</span><br />
			</div><br />
            <div class="superStar" id="test_1"><br />
				shit!<br />
				<div class="contne">hi</div><br />
				<ul><li>list</li></ul><br />
            </div>';<br />
<br />
$pattern = '/这里正则如何写/';<br />
preg_match($pattern, $subject, $matches);<br />
print_r($matches);<br />
<br />
$pattern_1 = '/这里正则如何写/';<br />
preg_match($pattern_1, $subject, $matches);<br />
print_r($matches);<br />
<br />
分别取到结果如下:<br />
数据一:<br />
you dead!<br />
<div class="show">hello</div><br />
<span>james</span><br />
<br />
数据二:<br />
shit!<br />
<div class="contne">hi</div><br />
<ul><li>list</li></ul>


请问正则要如何写才能取出上在的两个DIV中的内容呢。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn