This data header is a good match, and the end point is the match at the end
Then the most significant end of this string is the string ']})' (this string It should be json, but if it is json, it should end with five brackets like ']})]}'. Let's match it according to the ']})' data you provided)
So the regular expression is OK Write like this
$str=file_get_contents('/v3/music/top');
preg_match('/listData = ({.*?}]})/si', $str,$match);
echo $match[1].']}';
The output is a complete json
There is also The first method is to use regular balance group matching, but it is too troublesome to write, and because this json is missing the two brackets ']}', the balance group is unbalanced, so this is not recommended when method one is available. Writing method
This is related information about balanced group matching: web link