I\'m trying to do a PHP regular expression but i can\'t find the right way ...
Imagine I have this string: \"hello, my {{name is Peter}} and {{I want to eat chocolat
You want "ungreedy matching": preg_match("/{{(.*?)?}}/", $string)
.
Note the first question mark - a regex, by default, is "greedy": given multiple ways to match, it matches as much text as it possibly can. Adding the question mark will make it ungreedy, so if there are multiple ways to match, it will match as few characters as it possibly can.