D
Darwin
Hi,
I am trying to extract the host name from a HTTP header:
GET /1/1/typical.php HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, */*
Referer: http://www.httphost.com/1/1/
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
1.1.4322; .NET CLR 2.0.50727)
Host: www.httphost.com
Connection: Keep-AliveSo I just want to extract the text www.httphost.com
from the above. My code is below:
Regex r = new Regex(@"Host: ([A-Za-z0-9_:.]+)$", RegexOptions.Multiline);
// Match the regular expression pattern against a text string.
Match m = r.Match(message.ToString());
MessageBox.Show(m.Value);
But it shows a blank, I am sure there is an obvious answer.
I am trying to extract the host name from a HTTP header:
GET /1/1/typical.php HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, */*
Referer: http://www.httphost.com/1/1/
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
1.1.4322; .NET CLR 2.0.50727)
Host: www.httphost.com
Connection: Keep-AliveSo I just want to extract the text www.httphost.com
from the above. My code is below:
Regex r = new Regex(@"Host: ([A-Za-z0-9_:.]+)$", RegexOptions.Multiline);
// Match the regular expression pattern against a text string.
Match m = r.Match(message.ToString());
MessageBox.Show(m.Value);
But it shows a blank, I am sure there is an obvious answer.