I’m searching though IIS log files looking for lines where the 6th word contains h3.asp
Tried to make a regular expression, but it’s failing:
string text = @"2010-08-28 00:12:15 W3SVC591993719 192.168.10.13 GET /forum/h3.asp g=forum 80 - 10.10.10.10 Opera/9.80+(S60;+SymbOS;+Opera+Mobi/499;+U;+no)+Presto/2.4.18+Version/10.00 http://www.somesite.com/forum/default.aspx?g=posts&m=28078& www.somesite.com 200 0 0 62";
string pattern = @"(\w* ){5}\w*h3\.asp";
Console.WriteLine(Regex.IsMatch(text, pattern));
In the above sample I’m expecting a match, but clearly something is wrong.
How about this?
\S will match all non-whitespace, so this regex will match 5 groups consisting of non-whitespace followed by a single whitespace, followed by anything that contains “h3.asp”