April 16, 2023 • 2 min read
ChatGPT Generates Regex for AIDC App

CATEGORIES
SOCIAL SHARE
Improve Barcode Scanning Accuracy and Utility
Regular Expressions (aka “regex”) are already commonly used to increase the accuracy and efficiency of data capture and identification tasks, reducing errors and improving productivity. The CodeREADr app for iOS and Android OS devices has enabled the use of regex for many years now.
What’s New?
ChatCPT is a new tool to write regex code. Simply describe to Chat GPT the pattern and results you need and in seconds it generates the code. The website Regex101 can be used to test the code before deploying it.
Using these tools will allow non-developers to add regex codes to improve their data capture and collection accuracy. They will save time and money, as well.
Where to Use Regex?
There are at least four (4) areas to use regex to improve accuracy with the CodeREADr barcode scanning software.
- Alter Scanned Values. Here regex is used to change the scanned value to match the required result in a database.
- Alter Responses to Scanned Values. Here regex is used to display a specific response to an app user when a certain pattern is detected.
- Export Templates to Normalize Data. Here regex is used to change the format of the scanned data to match the format required in the target database.
- Custom On-Device Validation (COV). Here regex is used to stop app users from scanning barcodes that don’t match specific patterns. COV is a sophisticated, edge computing technology based on no-code/low-code implementations on the scanning device itself.
What are the best methods to query ChatGPT?
We found with ChatGPT your query needs to be very explicit based on the result you need. For example, to use the result with CodeREADr the query would be asked like this:
“Please provide a regex pattern and substitution input using an online regex tester like regex101.com to display the values from a UPC barcode with the leading zero and check digit removed.”
That is how we received the correct response in our example below under “Remove the Leading Zero and Check-Digit from UPC Barcode.” Note that if an input string is multiline, ask ChatGPT to include the multiline flag in the regex pattern. We did that for the GS1 examples below.
Inventory Audits and Cycle Counts
Example: Remove the Leading Zero and Check-Digit from UPC Barcode
Scanned UPC Value: 012345678901
Regex from ChatGPT
Pattern: ^0(\d{10})\d$
Replacement: $1
Regex101: https://regex101.com/r/rbcdLi/1
Result: The value “1234567890” will now accurately match the value in the inventory database.
Logistics
Example: Serial Number Extraction from GS1 Code-128
Scanned Value with serial number 12345678: (01)05410013111009(10)ABC123(21)12345678
Scanning Result
GTIN = (01)05410013111009
BATCH/LOT = (10)ABC123
SERIAL = (21)12345678
Regex from ChatGPT
Pattern: (?s).*\(21\)(\d+).*
Replacement: $1
Regex101: https://regex101.com/r/HjpEOL/1
Result: The serial number “12345678” can now be used to track where items have been shipped and deployed.
Medicine and Medical Equipment
Example: Lot Number Extraction from GS1 Code-128
Scanned Value with lot number 10003456789: (01)00314141999995(10)10003456789(21)20006500234
Scanning Result
GTIN = (01)00314141999995
BATCH/LOT = (10)10003456789
SERIAL = (21)20006500234
Regex from ChatGPT
Pattern: (?s).*\(10\)(\d+).*
Replacement: $1
Regex101: https://regex101.com/r/m93R0i/1
Result: The lot number “10003456789” can now be used to verify if it’s a recalled item.
What’s Next?
The future of using ChatGPT with CodeREADr looks very promising, as both technologies can complement each other for various use cases, especially when it comes to data capture, data collection, data connections, and process automation. Please email support@codereadr.com with “ChatGPT” in the subject line to learn more.