可能重複:
RegEx match open tags except XHTML self-contained tags
How to parse and process HTML with PHP?正則表達式在PHP,HTML採取
我需要幫助。我有HTML,我需要正則表達式給我表格。只有一張桌子。因爲在這張桌子上放了另一張桌子。 example html:
<table class="results" cellspacing="1" cellpadding="0" border="0" width="100%" align="left">
<tr><td>text</td></tr>
</table>
<!-style>
tr.bg_selected{}
tr.bg_selected td, tr.bg_checked td { background-color:#ffe9bc !important;}
</style>**AND ANOTHER TABLE**
它是我的常客。在那張桌子後面我得到所有桌子。
$regular = "/<table class=\"results\" cellspacing=\"(\d+)\" cellpadding=\"(\d+)\" border=\"(\d+)\" (.*)>(.*)<\/table>\n(.*)<\/style>/s";
preg_match_all($regular,$str, $matches2, PREG_PATTERN_ORDER);
請閱讀: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except- xhtml-self-contained-tags/1732454#1732454 – 2012-08-16 13:36:40
[The Pony,He Comes ...](http://stackoverflow.com/a/1732454/1338999)* HTML不是一種常規語言,因此不能被解析正則表達式。* – Matt 2012-08-16 13:36:49
@OcuS能否以更具建設性的方式重複該評論? – Matt 2012-08-16 13:39:32