正则匹配

 $str  = '姓名:{username},年龄:{age}';
 preg_match_all("/[{](.*?)[}]/", $str, $res);//加?,使用非贪婪模式
 return $this->success($res);
{
    "status": "true",
    "code": 200,
    "count": 0,
    "message": "操作成功",
    "data": [
        [
            "{username}",
            "{age}"
        ],
        [
            "username",
            "age"
        ]
    ]
}

 

posted @ 2021-11-04 16:48  CanyingV  阅读(25)  评论(0)    收藏  举报