Solved

C# Regex Help

Posted on 2013-10-29
2
343 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding where clause to entity statement c# 1 59
Visual C# Windows Project - Clone Form 4 37
What!!!??? 5 58
What is GIS method of Geometry data type? 6 28
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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…

739 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