title: ACH Pattern Match in C#
body: <p>I'm working on an Automated CLearing House (ACH) application and I'm doing the file validations.</p>
  <p>The first validation I need to validate that the ACH file has the correct pattern of record types.</p>
  <p>The pattern is this:</p>
  <pre><code>    1 - File Record Header
      5 - Batch Record Header
      6 - Entry Detail Record
      7 - Addenda Record
      8 - Batch Control Record
      9 - File Control Record
  </code></pre>
  <p>The number is the record type or the first character of the line. The text describes the record type.</p>
  <p>I want test that a file follows the above pattern..</p>
  <p>Some variations including the following..</p>
  <p>Addenda Record is not required</p>
  <pre><code>    1 - File Record Header
      5 - Batch Record Header
      6 - Entry Detail Record
      8 - Batch Control Record
      9 - File Control Record
  </code></pre>
  <p>File can have one or more batches..</p>
  <pre><code>1 - File Record Header
  5 - Batch Record Header
  6 - Entry Detail Record
  7 - Addenda Record
  8 - Batch Control Record
  5 - Batch Record Header
  6 - Entry Detail Record
  7 - Addenda Record
  8 - Batch Control Record
  5 - Batch Record Header
  6 - Entry Detail Record
  7 - Addenda Record
  8 - Batch Control Record
  9 - File Control Record
  </code></pre>
  <p>The File Record Header must be at the top of the file so the following would fail...</p>
  <pre><code>5 - Batch Record Header
  1 - File Record Header
  6 - Entry Detail Record
  7 - Addenda Record
  8 - Batch Control Record
  9 - File Control Record
  </code></pre>
  <p>Would RegEx be best for this? Any advice would be greatly appreciated.</p>