2
我正在使用preg_match_all(),我的問題是我無法創建我想要的模式。源文本的例子:創建模式爲php preg_match_all
<td align='left'>
<span style='font-size: 13px; font-family: Verdana;'><span>
</td>
<td>
<a style='color: #ffff00' rel='gb_page_fs[]' title='Parodyk kitiems 8 seriją' href='/pasidalink-19577x10/'>
<img src="/templates/filmai_black/images/ico_tool_share.gif" />
</a>
</td>
<td>
<small>LT titrai</small>
</td>
<td>
<a rel='gb_page_center[528, 290]' title='Žiūrėti 8 seriją' href='http://www.filmai.in/watch.php?em=BuwgzpqtssiAGGcjeekz9PTI1NjQ0N2E~'>
<img src="/templates/filmai_black/images/play_icon.png" width="20" onclick='set_watched_cookie_serial("19577x10", "done-tick-full-series")' />
</a>
</td>
我使用的模式:
<td><small>(.*)</small></td>
<td><a rel='gb_page_center[528, 290]' title='Žiūrėti (.*) seriją' href='(.*)'><img src=
我想要得到的位置的內容到一個數組(*)。
有人可以糾正我的模式並解釋它嗎? 我想學習使用正則表達式。
你不應該對'html'使用正則表達式,而應該使用'DOMDocument'。 –
是的,如果涉及HTML提取,沒有經驗的編碼人員會使用正則表達式語法。有[更簡單的選項](http://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-with-php)。 – mario