Home >Backend Development >PHP Tutorial > 这种正则表达式如何写?求高手解答

这种正则表达式如何写?求高手解答

WBOY
WBOYOriginal
2016-06-13 12:31:12894browse

这种正则表达式怎么写?求高手解答!
有一个网页中的代码如下:

<span class="1"><br />
      <h3 class="title">testtesttesttesttesttestt</h3><br />
      <div class="con"><br />
            <span>testtesttest</span><p>testtesttesttesttesttesttesttesttest</p><br />
      </div><br />
</span><br />
<div class="2"><br />
      <h3 class="title">testtesttesttesttesttestt</h3><br />
      <div class="con"><br />
            <span>testtesttest</span><p>testtesttesttesttesttesttesttesttest</p><br />
      </div><br />
</div><br />
<div class="3"><br />
      <h3 class="title">testtesttesttesttesttestt</h3><br />
      <div class="con"><br />
            <span>testtesttest</span><p>testtesttesttesttesttesttesttesttest</p><br />
      </div><br />
</div><br />
<span class="4"><br />
      <h3 class="title">testtesttesttesttesttestt</h3><br />
      <div class="con"><br />
            <span>testtesttest</span><p>testtesttesttesttesttesttesttesttest</p><br />
      </div><br />
</span><br />
...

大家注意到没有 class="1",class="2",class="3",...是有规律的,但是前面的标签没有规律,有时是span,有时是div,我想要的是用php如何写正则表达式获取class="1",class="2",class="3",...的内容,正则表达式这方面学的不好,试了半天都写不出来,求高手解答!

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