提取两个字符之间的文本

How can I best trim the following text outside the braces:

$myString = "10:0{ 'name':'John', 'age':30, 'car':null }24:0";

The text outside of the braces 10:0 and 24:0 may vary.

Just grab what's inside the braces:

preg_match('/{[^}]+}/', $myString, $match);
echo $match[0];

You can trim numbers and colons off with:

trim($myString, '0123456789:');

https://3v4l.org/vD7XC

... or you could replace everything outside the braces:

preg_replace('/.*?(\{.*?\}).*/', '$1', $myString);

https://3v4l.org/afN8B