2014-03-19 179 views
-1
$ohtml = '<!--#comp: {}-->I am HTML and whatever else<!--##comp-->'; 
preg_match_all('/\Q<!--#comp\E(.*?)\Q<!--##comp-->\E/', $othml, $match); 
print_r($match); 

完美的作品上http://regex101.com/但是在PHP它提出了500服務器錯誤PHP正則表達式工作regex101但不是在PHP

+1

請注意,您在這裏沒有任何可以逃脫的地方,您應該刪除所有無用的'\ Q ... \ E'。 –

回答

0

你的字符串是$ohtml但在正則表達式使用$othml。這是罪魁禍首!

$ohtml = '<!--#comp: {}-->I am HTML and whatever else<!--##comp-->'; 
    ^^ check here 

preg_match_all('/\Q<!--#comp\E(.*?)\Q<!--##comp-->\E/', $othml, $match); 
                  ^^ and here 
+0

謝謝。我必須工作太多...... –

相關問題