title: RegEx to capture repeating fields?
body: <p>I have a buffer I'm trying to parse with regular expressions.</p>
  
  <p>Here's an example of the buffer:</p>
  
  <pre><code>DATA#ALPHAONE;BETATWO.CHARLIETHREE!
  </code></pre>
  
  <p>The format is: The buffer always starts with "DATA#", as a literal header.
  After that it will have one-or-more text-fields separated by either a semicolon, period or exclamation.</p>
  
  <p>My Regex pattern (in C#) so far is:</p>
  
  <pre><code>string singleFieldPattern = "(?'Field'.*?)(?'Separator'[;.!])";
  string fullBufferPattern = "(?'Header'DATA#)(" + singleFieldPattern + ")+";
  </code></pre>
  
  <p>The problem comes when I try to dump the data that matched:</p>
  
  <pre><code>Regex response = new Regex(fullBufferPattern);
  string example = "DATA#ALPHAONE;BETATWO.CHARLIETHREE!";
  
  Debug.WriteLine("RegEx Matches?: {0}", response.IsMatch(example));  
  foreach (Match m in response.Matches(example))
  {
      foreach(string s in new string[]{"Header", "Field", "Separator"}) 
      {
          Debug.WriteLine("{0} : {1}", s, m.Groups[s]);
      }
  }
  </code></pre>
  
  <p>The only output is:</p>
  
  <pre><code>RegEx Matches?: True
  Header : DATA#
  Field : CHARLIETHREE
  Separator : !
  </code></pre>
  
  <p>I intended the output to be:</p>
  
  <pre><code>RegEx Matches?: True
  Header : DATA#
  Field : ALPHAONE
  Separator : ;
  Field : BETATWO
  Separator : .
  Field : CHARLIETHREE
  Separator : !
  </code></pre>
  
  <p>My expression did not get the earlier fields, <code>ALPHAONE</code> and <code>BETATWO</code> (and their Separators of <code>;</code> and <code>.</code>) as I intended.  It only captured the last field (<code>CHARLIETHREE</code>).</p>
  
  <p>How can I get all the parts that matched <code>singleFieldPattern</code>?</p>
  
  <p><hr>
  I've simplified my data format above for question purposes, but since some people want the real-data, here is much closer to the actual data:</p>
  
  <p><em>(Note:  values in <strong>[ ]</strong> are single-bytes that are unprintable, and spaces are for clarity only.)</em></p>
  
  <p>Example:</p>
  
  <pre><code>[SYN] % SYSNAMScanner[ACK]; BAUDRATE57600[ACK]; CTRLMODEXON[ACK];
  </code></pre>
  
  <p><strong>Translation:</strong><br>
     The System Name (SYSNAM) is "Scanner"<br>
     The baud rate is 57,600<br>
     The Flow Control is XON<br></p>