Stratosphere
Default Functions

Barcode Regexes

17min
the barcode regex is a regular expression that will be used to parse scanned product barcodes into the material code, serial number, batch number, and expiration date fields when adding items this increases the speed and accuracy of adding new items compared to manually typing in each of these fields example product and matching regex if you don't have access to a technical resource to help build your regular expressions, there are many online tools for aiding anyone in building and testing a regex to parse your product's barcode format we recommend regexstorm net http //regexstorm net/ which provides a quick reference of the characters used, as well as a tool for testing your regex by entering real (or simulated) barcodes and seeing how the regex you have built "reads" the barcode stratosphere uses the net regex engine, which will match this tool exactly let’s walk through a straightforward example of building a regex pattern to read a gs1 compliant barcoded product visible barcode (01)00123655093160(10)12345678(17)210831(21)12373438003(30)1 barcode output when scanned into barcode field ]c101001236550931601012345678172108312112373438003301 this barcode format contains four separate fields we want to parse gs1 code field value 01 itemnumber 00123655093160 10 batch 12345678 17 expirationdate 210831 21 serialnumber 12373438003 the final field, quantity, is not currently a field in stratosphere, but your regex will need to account for additional non parsed fields like this too only barcode regexes that match every character in a scanned barcode will be able to parse your barcode, so be sure to account for every character in the barcode, being as specific as possible, but allowing for a range of possible values where needed an example of a barcode regex that would match our example barcode output is ^(? \\]c1)?(? 01(?'itemnumber'\d{14}))?(? 10(?'batch'\d{8}))?(? 17(?'expirationdate'\d{6}))?(? 21(?'serialnumber'\d{11}))? $ let's break that down into its parts regex description ^ defines that the regex must start matching from the beginning of the input barcode without this, the regex could begin matching in the middle of the regex, increasing the risk of incorrect match (? \\]c1) instructs the regex to look for a subpattern that is literally the characters ]c1 these three characters are included in the example barcode scan as a prefix, though they do not contain product information ? allows for the absence of the preceding pattern, in this case "]c1" (? 01 matches a literal "01", which is the gs1 identifier that the following digits represent the item number (aka gtin) (?'itemnumber'\d{14})) (?'itemnumber' ) gives a name to the regex \d{14} \d means any digit (0 9) and the {14} indicates 14 consecutive characters altogether, this means that if there are 14 consecutive numbers at this place in the barcode, it should be read by stratosphere as the itemnumber and used to fill the product field ? allows for the absence of the preceding pattern, in this case "0100123655093160" (? 10 matches a literal "10", which is the gs1 identifier that the following digits represent batch (?'batch'\d{8})) (?'batch' ) gives a name to the regex \d{8} \d means any digit (0 9) and the {8} indicates 8 consecutive characters altogether, this means that if there are 8 consecutive numbers at this place in the barcode, it should be read by stratosphere as the batch and used to fill the batch field ? allows for the absence of the preceding pattern, in this case "1012345678" (? 17 matches a literal "17", which is the gs1 identifier that the following digits represent expiration date (?'expirationdate'\d{6})) (?'expirationdate' ) gives a name to the regex \d{6} \d means any digit (0 9) and the {8} indicates 6 consecutive characters altogether, this means that if there are 6 consecutive numbers at this place in the barcode, it should be read by stratosphere as the expiration date and used to fill the expiration date field ? allows for the absence of the preceding pattern, in this case "17210831" (? 21 matches a literal "21", which is the gs1 identifier that the following digits represent serial number (?'serialnumber'\d{11})) (?'serialnumber' ) gives a name to the regex \d{11} \d means any digit (0 9) and the {11} indicates 11 consecutive characters altogether, this means that if there are 11 consecutive numbers at this place in the barcode, it should be read by stratosphere as the serial number and used to fill the serial number field ? allows for the absence of the preceding pattern, in this case "2112373438003" any single characters these three characters are included in the barcode scan (quantity), but are not used $ defines that there should be no more characters at this point without this, the regex could match on a barcode that contains additional characters, increasing the risk of an incorrect match in our case, the expiration date format should be yymmdd to interpret 210831 as august 31st, 2021 if the barcode includes slashes or dashes between parts of the date, include this in your date formation for example, if the scanned barcode read 21/08/31, then you should account for the / characters in your regex and include slashes in the expiration date format field yy/mm/dd it is possible to make the regex example above even more specific for example, by requiring the 3rd number in the expiration date (21 0 831) to always be either a 0 or a 1, you could greatly increase the chance that this character really is the first number in the month making your barcode regexes as specific as possible is important if you are reading a wide variety or product barcode formats, and do not want these barcodes being interpreted by multiple barcode regexes stratosphere permits the addition of an unlimited number of barcode regexes to compare against, but multiple regexes should only be used if each one is sufficiently specific to avoid duplicate matches alternatively, the regex could be made quite loose to handle a wider variety of barcodes, by allowing multiple lengths for each group, permitting a broader range of characters, or by removing the ^ and $ beginning and ending anchors no regex workflow without a barcode regex that matches the scanned barcode, no information can be parsed into the item fields when adding a new item the product barcode becomes effectively a worthless string of numbers, and the batch, serial, product, and expiration date information must be manually entered, which takes about 20 30 seconds per item regex workflow with a barcode regex that matches the scanned barcode, information can be automatically parsed from the barcode into the item fields when adding a new item this turns adding an item into a matter of two quick barcode scans, and pressing "save changes," which takes about 3 4 seconds per item viewing barcode regexes viewing barcode regexes requires the "product management" role to be granted in your users docid\ oe8vd 0cdzxszxeukg19h record contact your system administrator to add this capability barcode regexes are viewed and managed inside the product catalog page, via the "manage barcode regexes" button to view a barcode regex's details, click the name of the barcode regex in the details page you will see all the available information for that barcode regex, including name an easily recognizable description of the barcode regex regex the regular expression used to parse the barcode into discrete data in stratosphere see example at the beginning of this article expiration date formation needed if the regex parses expiration date the regex can determine which numbers indicate the expiration date, but not what those numbers mean each number specified by the regex to be part of the expiration date must be interpreted as being part of the day, month, or year d stands for day m stands for month y stands for year = required adding barcode regexes adding barcode regexes requires the "product management" role to be granted in your users docid\ oe8vd 0cdzxszxeukg19h record contact your system administrator to add this capability barcode regexes are added to stratosphere in order to aid in the rapid addition of items, which can use any matching barcode regex to parse the item’s barcode for any useful data to automatically associate with the item you should make each regex you add as specific as possibl e to reduce the chance that the barcode regex will "match" on barcodes it is not intended to read for example, if you know the 1st character of a particular barcode will always be 0, specify 0 rather than just allowing any character, or even any number when a user is adding items docid\ efi2n49gjycru tk5huqm and the barcode they scan matches multiple barcode regexes, they will be forced to choose which of the matching regexes they want to use if a barcode matching multiple barcode regexes is a frequent occurrence, this will significantly slow down the addition of items if you are tracking product from multiple manufacturers, you will likely need to add (at least) one new barcode regex for every manufacturer even if they all follow gs1 or some other standard, the order, use of numbers vs letters, and length of various fields will likely differ making one regex work across many different manufacturers in these circumstances would result in a dangerously loose regex that risks misinterpreting barcodes to add a barcode regex, select "add barcode regex" in the top left of the barcode regex page enter a name, if desired enter a regex enter an expiration date formation, if the regex is parsing expiration dates click save changes to finish adding the barcode regex the barcode regex will appear in the barcode regexes table editing barcode regexes editing barcode regexes requires the "product management" role to be granted in your users docid\ oe8vd 0cdzxszxeukg19h record contact your system administrator to add this capability there are two options for editing a barcode regex option 1 on the barcode regex page, open the quick action menu for the barcode regex you wish to edit and select "edit " in the edit barcode regex window that opens, make any desired changes click "save changes" to save the edited record clicking "cancel" or the x in the top right of the window will remove any edits you just made but had not yet saved option 2 on the barcode regex page, click the barcode regex name link in the barcode regex details page, make any desired changes click "save changes" to save the edited record to cancel your edits, close or leave the barcode regex details page without saving deleting barcode regexes deleting barcode regexes requires the "product management" role to be granted in your users docid\ oe8vd 0cdzxszxeukg19h record contact your system administrator to add this capability deleting a barcode regex prevents items added in the future from using that barcode regex to parse an item's barcode it will not affect any existing items that may have utilized the barcode regex when they were added option 1 on the barcode regex page, open the quick action menu for the barcode regex you wish to delete and select "delete " in the "delete barcode regex" confirmation window that appears, click "delete" to confirm the deletion of the barcode regex clicking "cancel" or the x in the top right of the window will not delete the barcode regex option 2 on the barcode regex page, click the barcode regex name of the barcode regex you wish to delete on the barcode regex details page that opens, scroll to the bottom of the page and click "delete" in the "delete barcode regex" confirmation window that appears, click "delete" to confirm the deletion of the barcode regex clicking "cancel" or the x in the top right of the window will not delete the barcode regex barcode regex faq q what regex pattern syntax does stratosphere use? a stratosphere uses microsoft's net regular expression engine, which is based on the perl 5 standard see https //docs microsoft com/en us/dotnet/standard/base types/regular expression language quick reference https //docs microsoft com/en us/dotnet/standard/base types/regular expression language quick reference for more information, or use regexstorm net http //regexstorm net/ as a reference q can i name groups in my regex beyond the fields that stratosphere will use? manufacturing date, for example? a as long as the regex matches the barcode, stratosphere will fill in the fields it recognizes, while ignoring additional fields it will not cause an error or prevent the regex from matching q i have products with multiple barcodes, can i still use regexes when adding items? a yes, users adding items can scan in multiple barcodes to the barcode field (one at a time), and have each of them be parsed without clearing already parsed fields, as long as each barcode has a valid regex and their information does not conflict