I have string similar to this one:
{{something1}} something2 {{something3}} something4
How can I match only \"something1\" using the
a full answer - if our $var is:
STARTT
FIRST KKK
SECOND KKK
1) In case we use:
$var = preg_replace('/STARTT(.*)KKK/', 'REPLACED-STRING', $var);
it will change everything from the STARTT to last KKK and Result will be:
REPLACED-STRING
2) In case we use:
$var = preg_replace('/STARTT(.*?)KKK/', 'REPLACED-STRING', $var);
Result will be:
REPLACED-STRING
SECOND KKK
Use non greedy modifier ?
:
preg_match("/\{\{(.*?)\}\}/si",$content,$matches);
here --^
Try this:
preg_match('|{{([^}]+)}}|si', $content, $matches);
echo $matches[1];