0

您好,我有这个 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);

但它不起作用。任何建议为什么?

4

1 回答 1

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

处理缺失和多个空格、一attr="value"对或多对、多行并且是非贪婪的。

于 2012-07-28T15:41:55.837 回答