Page 1 of 1

Regular Expression

Posted: Thu Apr 02, 2009 3:09 am
by Deepa
I am a complete novice to Regex. Need help to achieve the below.
I have a file which has many lines as below 2 lines. From this i jus need to extract the time stamp and also the name following the pattern (.html?).
There may be instances when a line may have more than one instance of the pattern .html?. But i need to extract the name only once from each line.
Can someone help.

12.10.219.39 - msundbole330 [10/Mar/2009:12:53:51 -0500] "GET /landing.html?Jenifer%20Holly HTTP/1.0" 200 5983 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"
12.10.219.39 - msundbole330 [10/Mar/2009:12:53:51 -0500] "GET /images/lock.jpg HTTP/1.0" 304 0 "http://xxxxxx-xxxxxxs.xxxxxxx.com/ccccc.html?Jenifer Holly" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"

Thanks.

Posted: Thu Apr 02, 2009 10:20 am
by ben_josephs
What exactly do you want to do with the text you extract?
Which instance of .html? should be chosen if there's more than one of them?
How much text after .html? should be extracted? Everything up to the next "?

Posted: Thu Apr 02, 2009 7:46 pm
by Bob Hansen
Some other questions also....

1. When you get the time stamp do you also need the meridian offset (-0500 for example)?

2. Do you need the time adjusted by the offset to be local time?