$re = '/"Key":"X-Real-IP",\s*"Value":\[\s*"(?<X_Real_IP>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/m';
$str = '{
"Request":{
"Uri":"/api/...",
"requestHeaders":[
{
"Key":"X-Real-IP",
"Value":[
"213.205.240.26, 55.145.164.26"
]
},
{
"Key":"X-Forwarded-For",
"Value":[
"111.111.240.26"
]
},
"ContentHeaders":[
{
"Key":"Content-Length",
"Value":[
"0"
]
}
],
"Body":null
},
"Response":{ },
"TimeTakenMs":119
}
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php