我有以下一段代碼,它應該將提供的字符串與$ contents匹配。 $內容變量通過的file_get_contents存儲網頁內容()函數:preg_match_all刮在html標籤之間找到的詞
if (preg_match('~<p style="margin-top: 40px; " class="head">GENE:<b>(.*?)</b>~iU', $contents, $match)){
$found_match = $match[1];
}
在上述網頁上的原始字符串看起來是這樣的:
<p style="margin-top: 40px; " class="head">GENE:<b>TSPAN6</b>
我想匹配和存儲字符串「 TSPAN6'通過(。*?)在網頁上找到$ match [1]。但是,匹配似乎不起作用。有任何想法嗎?
瞭解哪些信息是靜態的以及哪些信息是字符串中的動態信息將很有用。你的模式適用於我的xampp btw。 '$ match [1] =='TSPAN6'' – 2012-08-10 23:30:08