Can you use the ungreedy modifier ?
, eg:
$regex = '/\{\{.*?\}\}/';
A new regular expression will appear:
Array ( [0] => Array ( [0] => {{content 1}} [1] => {{content 2}} ) )
EDIT:
Just remembered another way to do this. You can simply add U
(capital u) to the end of the regex line, and the result will be the same:
$regex = '/\{\{.+\}\}/U';
In addition, here is a useful list of regular expression modifiers .
source share