title: How Parsing string between [STX] and [ETX] using C# - Split/Append output using Regex or String Functions
body: <p><strong>Language = C#.NET</strong></p>
  
  <p><strong>Anything that is between [STX] and [ETX] must be accepted rest of the things must be rejected.</strong></p>
  
  <blockquote>
  <pre><code>string startparam = "[STX]";
  string endparam = "[ETX]";
  
  String str1 = "[STX]some string 1[ETX]"; //Option 1
  String str2 = "sajksajsk [STX]some string 2 [ETX] saksla"; //Option 2
  String str3 = "[ETX] dksldkls [STX]some string 3 [ETX]ds ds"; //Option 3
  String str4 = "dksldkls [STX]some string 4.1[ETX]ds ds [STX] some string 4.2[ETX] jdskjd"; //Option 4
  
  /* the various strings can be appended and converted to a single 
     string using string builder or treat them as different strings*/
  
  ProcessString (string str , string startparam , string endparam)
  {
     //What To Write here using RegEX or String Functions in c#
  
  }
  
  /* The output after passing these to a ProcessString () */     
  /* Append Output To a TextBox or Append it to a String using For Loop.*/
  
  /* Output Required */
  
  some string 1 
  some string 2
  some string 3
  some string 4.1 
  some string 4.2
  </code></pre>
  </blockquote>
  
  <p>=============================================================================</p>
  
  <h1>EDIT 2</h1>
  
  <pre><code>Language = C#
  
  string str = "
  [STX]some string 1[ETX]
  sajksajsk [STX]some string 2 [ETX] saksla
  [ETX] dksldkls [STX]some string 3 [ETX]ds ds
  dksldk[STX]ls [STX]some st[ETX]ring 4.1[ETX]ds ds [STX]some string 4.2[ETX] jdskjd";
  </code></pre>
  
  <p>How can i get the same output if the string array is one single string</p>
  
  <pre><code>/* output */
  some string 1 
  some string 2
  some string 3
  some string 4.1 
  some string 4.2
  
  
  /*case 1*/ 
  the above string can be "[STX] djkdsj [STX]dskd1[ETX] dsnds[ETX]" 
  the output should be just "dskd1"
  
  /*case 2*/ 
  the above string can be "[STX] djkdsj [STX]dskd1[ETX] ddd" 
  the output should be just "dskd1"
  
  /*case 3*/ 
  the above string can be " kdsj [STX]dskd1[ETX] dsnds[ETX]" 
  the output should be just "dskd1"
  
  /*case 4*/ 
  the above string can be "[STX] djk[STX]dsj [STX]dskd2[ETX] ddd" 
  the output should be just "dskd2"
  
  The real problem comes when [STX] followed by [STX] i want to consider the newer [STX] and start string processing from the newer [STX] occurance. Eg. Case 2 above
  </code></pre>
  
  <p>=============================================================================</p>
  
  <h1>EDIT 3 : New Request</h1>
  
  <p>Language = C#</p>
  
  <p>If i want the data between [STX] and [STX] also can that also be done.</p>
  
  <p>New RegEx which will extract data between
  1. [STX] some Data [STX]
  2. [STX] some Data [ETX]</p>
  
  <p>Eg.</p>
  
  <pre><code>/* the above string can be */
  "[STX] djk[STX]dsj [STX]dskd2[ETX] ddd" 
  /* the output should be just */
  djk
  dsj
  dskd2
  </code></pre>
  
  <p>As [STX] means a transmission has been started so i want to extract data between STX as well.</p>