RegEx & Code128 barcodes & GS1 (1 Viewer)

Ceebee86

Registered User.
Local time
Today, 02:33
Joined
Sep 9, 2019
Messages
25
Hi,

I'm quite new to access (4-5 months) and RegEx.

I've searched the internet so much over past few days, tested with regex101.com and I can't get it right.

I have a regex module which lets me use it in access as a function.

I have a few suppliers, and their bar codes are all different, with the GS1 identifiers in different places.

02050604029067253700000100 - Supplier 1

370091919322223002 - Supplier 2

020761303548292020031520090037801092651042d - Supplier 3

I want to capture the below

02 - GTIN of Trade Items Contained in a logistic unit - Format - n2+n14 (Always 14 digits)

Original Expression: 02(\d{14})37
Internet sourced expression: /^02(\d{14})/


10 - Batch or lot number - Format - n2+an..20 (Up to 20, but not exceed 20)

Original Expression: 10(.{6,10})$
Internet sourced expression:/^10([^\u001D]{1,20})/

11 - Production date (YYMMDD) - Format - n2+n6 (always 6 digits)

Original Expression: 11(\d{6})10
Internet sourced expression: None

15 - Best before date (YYMMDD) - Format - n2+n6 (always 6 digits)

Original Expression: 15(\d{6})[10,11]
Internet sourced expression: /^15(\d{6})/

37 - Count of trade items contained in a logistic unit - n2+n..8 (Up to 8 digits)

Original Expression: 37(\d{4,8})
Internet sourced expression: /^37(\d{1,8})/

00 - SSCC (Serial Shipping Container Code) - Format - n2+n18 (always 18 digits)

Original Expression: ^00\d{18}|^.{18}$
Internet sourced expression: Didn't have to find one, this one seems to work fine.

The regular expressions I had already were aimed for Supplier1, and don't seem to take into account all other combinations. (I didn't write them, and I'm struggling to modify them.)

So, how do I write these to take into account all combinations, that each identifier might appear in each others string, and to be consistent? Is this a task for a high end programmer, and not an amateur like me, as I have seen a few posts with similar problems where C# and Python developers struggle? Am I aiming too high for my current abilities?

Or is it just as simple as me getting the syntax right?

For example, I tried 37(\d{2,6})(91|02|11|12|13|15|17|20|99|10)

02050604029067253700000100 - Supplier 1

Captuered: 00000
Should capture: 00000100

370091919322223002 - Supplier 2

Captured: 0091
Should capture: 0091

020761303548292020031520090037801092651042d - Supplier 3

Captured: 80
Should capture: 80

PS. I only have VBA and access available to me, no other languages etc.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:33
Joined
Sep 21, 2011
Messages
14,037
I would construct a Regex expression string for each supplier, and store in a table with their other details.
Then lookup the regex expression for the required supplier and apply that.?

HTH
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:33
Joined
Oct 29, 2018
Messages
21,357
Hi. I'm not sure I understand your question. Based on Gasman's response, were you asking how to check one input against three different patterns? What if it matches more than one?
 

Ceebee86

Registered User.
Local time
Today, 02:33
Joined
Sep 9, 2019
Messages
25
I would construct a Regex expression string for each supplier, and store in a table with their other details.
Then lookup the regex expression for the required supplier and apply that.?

HTH

Thank you! This method works well for me :) I tried this on Sunday and it worked a charm. :) Thank you for digging me out of a rut!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:33
Joined
Oct 29, 2018
Messages
21,357
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Ceebee86

Registered User.
Local time
Today, 02:33
Joined
Sep 9, 2019
Messages
25
Hi. I'm not sure I understand your question. Based on Gasman's response, were you asking how to check one input against three different patterns? What if it matches more than one?

That was my problem, I was trying to do a one regex fits all possible combinations with GS1 identifiers....but its not that simple, and Gasman's simple approach has helped me out immensely, had tunnel vision. :(
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:33
Joined
Oct 29, 2018
Messages
21,357
That was my problem, I was trying to do a one regex fits all possible combinations with GS1 identifiers....but its not that simple, and Gasman's simple approach has helped me out immensely, had tunnel vision. :(
Nice going, Gasman. Cheers!
 

Users who are viewing this thread

Top Bottom