Regex extract string between 2 curly braces

后端 未结 5 1878
梦如初夏
梦如初夏 2020-12-11 23:20

I have the following short codes:

Dear {{name}},

You are being invited for the following event: {{event}}

5条回答
  •  悲哀的现实
    2020-12-11 23:36

    With preg_match_all():

    $pattern = '~\{\{(.*?)\}\}~';
    preg_match_all($pattern, $string, $matches);
    var_dump($matches[1]);
    

提交回复
热议问题