0

New to C#. I'm parsing for a lotNumber in a 2D barcode. The actual lotNum 'A2351' is hidden in this barcode string ""+M727PP011/$$3201001A2351S". I would like to break this barcode up in separate string blocks but the delimiters are not consistent.

The letter prefix in front of the 4 digit lot number can be a 'A', 'P', or a 'D' There is a single letter following the lot number that can be ignored.

string Delimiter = "/$$3"; 

//barcode format:M###PP###/$$3  yymmdd lotnumprefix 'A' followed by lotNum    
string lotNum= "+M727PP011/$$3201001A2351S";  

string[] split = lotNum.Split(new[] {Delimiter}, StringSplitOptions.None);
Di Chang
  • 1
  • 1
  • Yes, you can. Look here: [link](https://stackoverflow.com/questions/1126915/how-do-i-split-a-string-by-a-multi-character-delimiter-in-c). – Bassel Bitar Jul 18 '17 at 23:55
  • Just as you can't, we can't write this for you without a thorough specification. Write down this specification in English, and you'll find it'll be trivial to implement. For starters, is the separator always an "A"? Will that always be the only "A" present in that string? Is the "lot number" you're looking for always of the same length? What is the relevance of the "S" following it? And so on. – CodeCaster Jul 19 '17 at 18:39

0 Answers0