title: Parsing an inconsistent log file
body: <p>I have a log file that I want to parse and load into a database. I'm struggling with the best way to go about parsing it. </p>
  
  <p>The log file is in the format <em>Category: Information</em></p>
  
  <pre><code>Case Number: CASE01  
  User ID: JOSM  
  Software: Microsoft Word  
  Date Started: 21-01-2010  
  Date Ended: 22-01-2010  
  </code></pre>
  
  <p>Thing is, there's other bits and pieces thrown into the log file that mean the information isn't always present on the same line. I also only want the information, not the category. </p>
  
  <p>So far, I've tried stick it all into an array separated by \r\n, but I have to know the index of the information I want in order to consistently retrieve it, and that changes. I've also tried feeding it through StreamReader and saying</p>
  
  <pre><code>if (line.Contains("Case Number"))
  {
      tbReport.AppendText("Case Number: " + line.Remove(0, 13) + "\r\n");
  }
  </code></pre>
  
  <p>Which gets me the information I want, but makes it very hard to do anything with. </p>
  
  <p>I feel I'm better off going down the array path, but I could do with some guidance on how to search the array for the the category, and then parse the information.</p>
  
  <p>Once I can parse it accurately, adding it into a database should be fairly straight forward. As it's my first time attempting this, I'd be interested in any tips or guidance as to the best way to go about this though. </p>
  
  <p>Thanks. </p>