Regex to match placeholders

Let’s say I have a twig template and I would like to match every placeholder occurence

Hi {{ }},
this is just an {{ }}

If I use in php this regex: /{{2}([^}]+)}{2}/

I will obtain as output not only the placeholders but even the content (so, basically, this)

   0 => {{ }}
   1 => {{ }}
   0 =>
   1 =>

How can I isolate only the whole placeholder? (So, basically, how can I obtain only first slug of array?)

Source: regex

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.