GS1 is the global standard for product identification and supply chain labeling. Its barcodes are used on over 1 billion products worldwide. They encode product identifiers (GTIN), expiry dates, batch and lot numbers, serial numbers, quantity, weight and volume, healthcare IDs such as GSRN and GDTI, and shipment and location data such as SSCC and GLN.
Each value is tagged with an Application Identifier, the short number that tells software what follows it. Your app receives them run together in one string. A GTIN and an expiry date always have the same length, so nothing marks where they end. Batch and serial numbers vary in length, so an ASCII 29 group separator closes any variable-length field that isn't last.
Code that splits the string at fixed positions breaks on the first label that differs from the sample. A GS1 parser reads the AIs and their rules instead. See a worked example in what a medicine barcode holds and how to parse it.