•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 427,859 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,671 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 5592 | Replies: 3
![]() |
•
•
Join Date: Sep 2006
Posts: 104
Reputation:
Rep Power: 3
Solved Threads: 0
I have a text file say log file. i have to extract all the characters between "<" sign and ">" sign.
i.e. between <> and put it into the database and log file is of kind
Sun, 24 Jun 2007 21:49:49 GMT: Received request </abc/abc.gif>, from <111.1.11.11>:<1111> at domain <localhost/abc.net>
Sun, 24 Jun 2007 21:49:49 GMT: UserName <abc>, Proxy <localhost-80>, URN <http://abc/abc.gif>
Sun, 24 Jun 2007 21:49:49 GMT: Processing Proxy request
Sun, 24 Jun 2007 21:49:50 GMT: Sending Msg <111> from Proxy Reader <1111111111> for URL <http://abc.abc/>with Params <> <abc>
Sun, 24 Jun 2007 21:49:50 GMT: Named pipe <\\.\pipe\1111111111> started for request <http://abc.abc/>
Sun, 24 Jun 2007 21:49:50 GMT: Received request </abc/abc.gif>, from <111.1.11.11>:<1111> at domain <localhost/abc.net>
Sun, 24 Jun 2007 21:49:50 GMT: UserName <abc>, Proxy <localhost-80>, URN <http://abc/abc.gif>
Sun, 24 Jun 2007 21:49:50 GMT: Processing Proxy request
Sun, 24 Jun 2007 21:49:52 GMT: Received Msg <222> for URL <http://abc.abc/>
Sun, 24 Jun 2007 21:49:52 GMT: Status: 200 OK, Reminder: Server: Microsoft-IIS/5.1
X-Powered-By: ASP.NET
Date: Mon, 25 Jun 2007 04:48:33 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Thu, 22 Mar 2007 05:29:17 GMT
Sun, 24 Jun 2007 21:49:52 GMT: Last chunck read from pipe \\.\pipe\1111111111 for <http://abc.abc/>: <963>
Sun, 24 Jun 2007 21:49:52 GMT: Closing pipe <\\.\pipe\1111111111> for url <http://abc.abc/>
and i want to parse this file and extract and put the information from <> sign into the database
i had followed following link for file parsing
and instead of putting the info in dataset i m putting it into database.
Now my problem is my log file is of above format and i have to parse all the info within <>
I m using C# 1.1 version
does anybody have any idea or suggestions?
Thanks in advance
i.e. between <> and put it into the database and log file is of kind
Sun, 24 Jun 2007 21:49:49 GMT: Received request </abc/abc.gif>, from <111.1.11.11>:<1111> at domain <localhost/abc.net>
Sun, 24 Jun 2007 21:49:49 GMT: UserName <abc>, Proxy <localhost-80>, URN <http://abc/abc.gif>
Sun, 24 Jun 2007 21:49:49 GMT: Processing Proxy request
Sun, 24 Jun 2007 21:49:50 GMT: Sending Msg <111> from Proxy Reader <1111111111> for URL <http://abc.abc/>with Params <> <abc>
Sun, 24 Jun 2007 21:49:50 GMT: Named pipe <\\.\pipe\1111111111> started for request <http://abc.abc/>
Sun, 24 Jun 2007 21:49:50 GMT: Received request </abc/abc.gif>, from <111.1.11.11>:<1111> at domain <localhost/abc.net>
Sun, 24 Jun 2007 21:49:50 GMT: UserName <abc>, Proxy <localhost-80>, URN <http://abc/abc.gif>
Sun, 24 Jun 2007 21:49:50 GMT: Processing Proxy request
Sun, 24 Jun 2007 21:49:52 GMT: Received Msg <222> for URL <http://abc.abc/>
Sun, 24 Jun 2007 21:49:52 GMT: Status: 200 OK, Reminder: Server: Microsoft-IIS/5.1
X-Powered-By: ASP.NET
Date: Mon, 25 Jun 2007 04:48:33 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Thu, 22 Mar 2007 05:29:17 GMT
Sun, 24 Jun 2007 21:49:52 GMT: Last chunck read from pipe \\.\pipe\1111111111 for <http://abc.abc/>: <963>
Sun, 24 Jun 2007 21:49:52 GMT: Closing pipe <\\.\pipe\1111111111> for url <http://abc.abc/>
and i want to parse this file and extract and put the information from <> sign into the database
i had followed following link for file parsing
and instead of putting the info in dataset i m putting it into database.
Now my problem is my log file is of above format and i have to parse all the info within <>
I m using C# 1.1 version
does anybody have any idea or suggestions?
Thanks in advance
<.+?> Last edited by iamthwee : Jun 25th, 2007 at 1:31 pm.
I'm not a programmer. My attitude starts with ignorance, holds steady at conversation, and ends with a trip to the hospital. Get used to it.
This
For some tutorials on C# regexes see here.
<([^>]+)> would probably be what you were looking for. Since I don't know the C# Regex API (neither C#), I can't help you in that area, but as long as you know how to use back-references and extract the matched text, this shouldn't be a major problem.For some tutorials on C# regexes see here.
Last edited by ~s.o.s~ : Jun 25th, 2007 at 2:46 pm.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: Aug 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Regex r;
Match m;
string inputString = "sdasdsf < Muhammad > dffafsdfsfssd < Afnan > fdgdfsagff <Khan> sdsdf dssdsdfsdsdfsdf<lastafnan@hotmail.com>sdfsdfsdffsdsdfsdfsdffsdfsdfsd";
r = new Regex("(<.+?>)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
for (m = r.Match(inputString); m.Success; m = m.NextMatch())
{
Console.WriteLine("Found:" + m.Groups[1] + "at" + m.Groups[1].Index);
}
Console.ReadLine(); Last edited by ~s.o.s~ : Aug 24th, 2008 at 4:50 am. Reason: Added code tags, learn to use them.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Open In New Window Php (PHP)
- In Desperate Need of Help with hijack this log file; computer full of spyware (Viruses, Spyware and other Nasties)
- HiJackThis Log File... (Viruses, Spyware and other Nasties)
- Bridge.dll error please help me here is my hijackthis log file! (Viruses, Spyware and other Nasties)
- ANOTHER hijackthis log file..help! (res://mshp.dll, lookfor.cc) (Viruses, Spyware and other Nasties)
- HijackThis log file (Viruses, Spyware and other Nasties)
Other Threads in the C# Forum
- Previous Thread: how to count?
- Next Thread: EvenOdd



Linear Mode