I have a text like:
Title A
some description on a few lines, there may be empty lines here
some description on a few lines
Status: some random text
Title B
some description on a few lines, there may be empty lines here
some description on a few lines
Status: some other random text
Title C
some description on a few lines, there may be empty lines here
some description on a few lines
Status: some other random text
I want to parse the text based on the literal Status: and get an array of items, each with title, description lines and status. I’m using C# 4.0.
This is how I would do it (assuming it is read from text file):
You could then take the arrays and store it in some class if you wanted. I will leave that up to you to figure out. It just uses a simple regex to check if the line starts with
“Status:” or “Title:”. Truth be told, that isn’t even needed. You could do something like:
To check if each line starts with Status or Title.