remove lex tag block from string

240 Views Asked by At

Hello i have this lex parser template which contains a callback tag which i want to be removed because i get an infinite loop.

I tried with php preg_replace but then i get a white screen. The tag that i want to remove is in this format:

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

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

{{ /search:query }}

And this is my try at preg_replace:

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

But it doesn't work. Any advice why?

1

There are 1 best solutions below

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

Handles missing and multiple whitespace, one or more attr="value" pairs, multi-line and is non-greedy.