So I have this string which I want to serialize as a GS1 Data Matrix:
var code = (01)09501101020917(17)190508(10)ABCD1234(410)9501101020917
According to the Guidelines this isn't valid, because the Application Identifier (10) has a variable length so I need a (ascii code 29) separator at the end of that section (so something like this
"(10)ABCD1234{(char) 29}"
So I split my input string into parts, one part the Application Identifier (AI) and the other part being the data.
My Regex and code for getting the AIs:
var identifierRegex = new Regex(@"\([0-9]{2,}\)", RegexOptions.ExplicitCapture);
var identifiers = identifierRegex.Split(code);
This returns me almost the correct result, identifiers
is a string[]
containing 5 elements, the first one being empty and the rest are correct.
My Regex and code for getting the AIs and the data:
var dataRegex = new Regex(@"\([0-9]{2,}\)[0-9A-z]{0,}", RegexOptions.ExplicitCapture);
var aisAndData = dataRegex.Split(code);
This returns me the completely wrong results, aisAndData
is a string[]
with 5 empty elements
Here is a link to regexstorm.net showing the expected results of the first Regex. And Here is a link to regexstorm.net showing the expected result of the second Regex
What am I missing/ what am I doing wrong for my code not to work?