0

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?

David Gorsline
  • 4,933
  • 12
  • 31
  • 36
SirCumz
  • 171
  • 1
  • 2
  • 14

1 Answers1

0
$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.

Tisho
  • 8,320
  • 6
  • 44
  • 52