As you may noticed i highlighted a few digits in bold, where is:
01: Article code, 17: date in yy/mm/dd format 10: Lotnr 21: serialnr
I am able to take the first bit apart that is the article code as it is always the prefix (01) followed by 14 digits so in my code i take away the 01 and keep the 14 digits string as an article code. I save the split string in a variable and here is were the problem begins.
I noticed in most barcodes the date with prefix (17) and 6 digits follows after the article code (01) 14 digits. In that case its easy to cut the date from the string as it is always 6 digits. In some barcodes the serialnr (21) follows after the article code (01). Here is where it gets tricky. The serialnr has a variable amount of digits. I can filter the restant of the string, after cutting off the article code (01), to search for the digits (17) and filter from there to the next prefix. But when the serialnr has a prefix in it i need some sort of logic to skip those 2 digits and continue to the next match of prefix based on a min max amount of characters.
Did anybody ran in some sort of problem like this before of knows a topic on the net that could point me in the right direction. In my opinion this will never be 100% fail save if an amount of numbers to cut out have a variable amount and have a variable place. I need matching in the string but what when a string is 2121212121 as serial number that uses (21) as prefix.
I am seriously brainfarting on this, i appreciate all the hints that could point me in the right direction!