日期:2014-05-17  浏览次数:20547 次

正则匹配,求帮忙
<html>
<body>
<div class="rscl"></div>
<div class="listNews">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
</div>
</body>
</html>
-------------------------------------------------
我要匹配上面html代码中 <div class="listNews">之后 第一个</div> 之中的内容 正则该怎么写喃

也就是匹配出如下内容:
---------------------------------------------------
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">
  <ul class="iconBoxT14">

------解决方案--------------------
/<div\s+class=\"listNews\">(.*)<\/div>/isU 用这个试下

PHP code

$strHtml = <<<str
            <html>
            <body>
            <div class="rscl"></div>
            <div class="listNews">
            <ul class="iconBoxT14">
            <ul class="iconBoxT14">
            <ul class="iconBoxT14">
            <ul class="iconBoxT14">
            <ul class="iconBoxT14">
            <ul class="iconBoxT14">
            <ul class="iconBoxT14">
            <ul class="iconBoxT14">
            <ul class="iconBoxT14">
            </div>

            <div>3333</div>
            </body>
            </html>
str;
preg_match("/<div\s+class=\"listNews\">(.*)<\/div>/isU",$strHtml,$match);
echo '<pre>';
var_dump($match);