Home Forums Barcode Generator GTIN Barcode using the Barcode Rules Reply To: GTIN Barcode using the Barcode Rules

Insight WorksInsight Works
    Post count: 3

    Hi Andrew,

    To Match (02)09420036400(15)191017(37)20 you will need to change two things in your regex expression.

    First, escape your parenthesis you are matching with backslashes. Regex will otherwise interpret them as a Matching Group.

    Second, move your matching group (.*) behind the static prefixes to make sure you only pull in the values and not the prefix along into it. I.E., You wouldn’t want a quantity of (37)20, instead you want just 20.

    Try this regex expression: \(02\)(.*)\(15\)(.*)\(37\)(.*)

     

    Now if you have the batch and total net weight in your barcode as well make sure to take that into account in your regex expression because the Barcode Rules above will grab everything after (37) as the %3 value. So if your barcode also contains the groups ’10’ & ‘3102’ in the order your provided then do something like this:

    \(02\)(.*)\(15\)(.*)\(37\)(.*)\(10\)(.*)

    In this regex expression you will get all your required values for %1,%2,%3, and %4 will grab anything afterwards (10 & 3102).

     

    You can use this third party website, https://regexr.com,  to learn more about matching groups. I always recommend being as strict as possible to the same rules the barcode creator applies to the given barcodes.