using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\s*([JSESSIONID]+)\s*=\s*(?:""([^""])""|([^;""]*))\s*";
string input = @"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";
Match m = Regex.Match(input, pattern);
Console.WriteLine("'{0}' found at index {1}", m.Value, m.Index);
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx