The lazy repetition answers work great, but I personal avoid it when possible (since we can be more "specific" with what we want to match). I would use this expression:
\{{2} (?# match 2 literal {)
( (?# start capture group)
[^}]+ (?# 1+ non } characters)
) (?# end capture group)
\}{2} (?# match 2 literal })
This captures 1+ non-}
characters, meaning it will stop as soon as it sees the closing }}
. However, this means a {{foo}bar}}
template would not work (however, I don't think that would be a problem).
Implementation:
preg_replace_all("/\{{2}([^}]+)\}{2}/", $this->outputHtml, $matches);