Regex extract string between 2 curly braces

后端 未结 5 1874
梦如初夏
梦如初夏 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:38

    Use preg_match to match the text between 2 curly braces :

    $subject = "{{Lorem}}";
    $pattern = '/\{\{([^}]+)\}\}/';
    preg_match($pattern, $subject, $matches);
    var_dump($matches);
    

    Take a look at similar Question

提交回复
热议问题