Regex: Mathing formatted multi-line reports

  • Thread starter Thread starter B Loggins
  • Start date Start date
B

B Loggins

Hi everyone, I have reports of the form:

Name: Value
Name2: Value

And so on... the report is padded right on the value so the colons
line up properly. I can match this pretty well, but some of the
attributes have multiline values. Here's an example:

Name: John Doe
Phone: 555-5555
City: Dallas, TX
FavoriteBands: Metallica
Korn
Filter
Mood: Happy

Basically, I don't have a problem matching lines like " Name:
John Doe", but how do I make a regular expression that knows to match
Metallica, Korn, and Filter under Favorite Bands, then continue as
normal with "Mood" => "Happy"?

Thanks in advance for the help, and my apologies if this is a FAQ. I
tried to find something on it but to no avail.
 
Hi everyone, I have reports of the form:

Name: Value
Name2: Value

And so on... the report is padded right on the value so the colons
line up properly. I can match this pretty well, but some of the
attributes have multiline values. Here's an example:

Name: John Doe
Phone: 555-5555
City: Dallas, TX
FavoriteBands: Metallica
Korn
Filter
Mood: Happy

Basically, I don't have a problem matching lines like " Name:
John Doe", but how do I make a regular expression that knows to match
Metallica, Korn, and Filter under Favorite Bands, then continue as
normal with "Mood" => "Happy"?

Thanks in advance for the help, and my apologies if this is a FAQ. I
tried to find something on it but to no avail.

Oh, sorry for the spacing problems, the google font is proportional
width. Basically, that report looks "pretty" in a fixed width font
with everything lining up
 
With MultiLine and ExplicitCapture on:

^\s*(?<key>[^:]+):(?<value>([^:]+$)+)


* B Loggins wrote, On 23-2-2007 0:36:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top