Solved

C# Regex Help

Posted on 2013-10-29
2
348 Views
Last Modified: 2013-11-16
Hi,

Can I get some help with a regex code for C#.

Here is my starting line of text.

<![LOG[==========[ ccmsetup started in process 3172 ]==========]LOG]!><time="14:32:31.717-600" date="07-29-2013" component="ccmsetup" context="" type="1" thread="908" file="ccmsetup.cpp:9100">==========[ ccmsetup started in process 3172 ]==========]LOG]!><time="14:32:31.717-600" date="07-29-2013" component="ccmsetup" context="" type="1" thread="908" file="ccmsetup.cpp:9100">

Open in new window


I want to capture the following fields.

<![LOG[Data in here]LOG]!>

So the first captured field would be:

==========[ ccmsetup started in process 3172 ]==========

The next field the time:  14:32:31.717-600

the date:

07-29-2013

component:

ccmsetup

and finally the thread:

908

And also have this match over multiple lines so I can read the whole file into one string and have it parse it all in one hit.

Thanks,

Ward.
0
Comment
Question by:whorsfall
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 39608472
try this

\<\!\[log(.+?)(?:\]log\]\!\>)

Open in new window

HTH

Ivo Stoykov
0
 
LVL 9

Accepted Solution

by:
Derek Jensen earned 500 total points
ID: 39609538
This regex seemed to work well for me, though it trips up on the 'type' attrib(because of the "" before it); however if you don't care about anything after 'thread', then you should be set! :-)

(\w+)?=\"?(.+?)(?=\]log|")

Open in new window

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question