$re = '/\s*([JSESSIONID]+)\s*=\s*(?:"([^"])"|([^;"]*))\s*/';
$str = 'HTTP/1.1 302 Found
Date: Fri, 10 Jun 2016 21:44:38 GMT
Set-Cookie: JSESSIONID=1n9rk5co2o4xkpr327clod1pu;Path=/genesys;Expires=Sat, 11-Jun-2016 21:44:38 GMT;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Location: http://192.168.1.200:8010/genesys/admin/login.jsp#/
Content-Length: 0';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 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