title: EAN128 or GS1-128 decode c#
body: <p>Here is the sample of EAN128  or new name GS1-128 barcode</p>
  
  <blockquote>
    <p>01088888931021461712031510W1040190 </p>
  </blockquote>
  
  <p>I want to decode it to ais </p>
  
  <blockquote>
    <p>(01)08888893102146<br>
    (17)120315<br>
    (10)W1040190</p>
  </blockquote>
  
  <p>But the barcode can be changed like this</p>
  
  <blockquote>
    <p>1712031510W1040190<br>
    (17)120315<br>
    (10)W1040190</p>
  </blockquote>
  
  <p>is there any possible ways to solve it with regex or what is the better way</p>
  
  <p>Now I am trying this</p>
  
  <pre><code>public String AICodes(String pAI)
      {
          switch (pAI)
          {
              case "01":
                  return "01\\d{14}";
              case "17":
                  return "17\\d{6}";
              case "10":
                  return "17\\d{6}10[a-zA-Z0-9|]{1,20}";
          }
          return String.Empty;
      }
  
  private void GS1DataConvert(string pBarcode, string pBarfnc)
      {
         Match match = Regex.Match(pBarcode, AICodes(pBarfnc));
          if (match.Success)
          {
              MessageBox.Show(match.Groups[0].Value);
          }
      }
  
  string barfnc = "01";
  
  GS1DataConvert(barcode, barfnc);
  barfnc = "17";
  GS1DataConvert(barcode, barfnc);
  barfnc = "10";
  GS1DataConvert(barcode, barfnc);
  </code></pre>