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 chocolate}}”
I want to take the parts between {{ and }}
But if I use preg_match("/\{\{(.*)?\}\}/", $string)
it returns me jut one string “{{name is Peter}} and {{I want to eat chocolate}}”
How can I tell to take the first coincidences of }} ?
Thank you
Use
The expression
".*"is greedy, taking as many characters as possible.If you use
".*?"is takes as little characters as possible, that is it stops at the first set of closing brackets.