2012-07-25 24 views
0

您好,我有這個lex解析器模板,其中包含一個回調標記,我想刪除它,因爲我得到一個無限循環。從字符串中刪除lex標記塊

我試着用php preg_replace,但後來我得到一個白色的屏幕。我想刪除的標籤的格式如下:

{{ search:query term="value" .. more attributes .. }} 

    // any content between these tags needs to be removed as well, including new lines 

{{ /search:query }} 

這是我嘗試做了preg_replace:

$text = preg_replace('@\{\{\ssearch:(.*?)\}\}(.*?)\{\{\s/search:(.*?)\s\}\}@is','',$text); 

但它不工作。任何建議爲什麼?

回答

0
$text = preg_replace('\{\{\s+search:query(\s+\S+=".*")+\s*\}\}.*\{\{\s*/search:query\s*\}\}Uims', '', $text); 

把手缺失和多個空白,一個或多個attr="value"雙,多線和非貪婪。