在php preg_match中如何在花括号之间提取字符串和特殊字符

在php preg_match中如何在花括号之间提取字符串和特殊字符,php,regex,preg-match,preg-match-all,Php,Regex,Preg Match,Preg Match All,我有这样的绳子 $string ="this is test {username} ,{password@123} and Other {asdfg@#$}" 我想要这个字符串作为数组格式,如下所示 [1] => Array ( [0] => username [1] => password@123 [2] => asdfg@#$ ) (? 这给了你想要的谢谢你,伙

我有这样的绳子

$string ="this is test {username} ,{password@123} and Other {asdfg@#$}"
我想要这个字符串作为数组格式,如下所示

[1] => Array
        (
            [0] => username
            [1] => password@123
            [2] => asdfg@#$
        )
(?

这给了你想要的

谢谢你,伙计,按照我的要求工作
(?<={)[^}]+(?=})
$re = "/(?<={)[^}]+(?=})/mi";
$str = "this is test {username} ,{password@123} and Other {asdfg@#\$}";

preg_match_all($re, $str, $matches);
$re = "/\{(.*?)\}/";
$str = "this is test {username} ,{password@123} and Other {asdfg@#\$}";

preg_match_all($re, $str, $matches);

print_r($matches);