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 dramatically 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 which provides a quick reference of the character's 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 Example

Barcode Output when scanned into Barcode field: ]C101001236550931601012345678172108312112373438003301

This barcode format contains four separate fields we want to parse.

GS1 CodeFieldValue
01itemnumber00123655093160
10

batch

12345678
17expirationdate210831
21serialnumber12373438003

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 barcode regex that would match our example barcode is: ...01(?'itemnumber'\d{14})10(?’batch’\d{8})17(?'expirationdate'\d{6})21(?'serialnumber'.{11})...

Let's break that down into it's parts:

RegexDescription
...any single characters. These three characters are included in the barcode scan, though they do not contain product information.
01matches a literal "01", which the the GS1 identifier that the following digits represent itemnumber
(?'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.
10matches 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.
17matches 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{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 expiration date and used to fill the expiration date field.
21matches 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 8 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.
...any single characters. These three characters are included in the barcode scan, though they do not contain product information.

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 yoru 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 (210831) 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.

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. Always use barcode regexes when possible! The users who are responsible for adding items will thank you.

Viewing Barcode Regexes

Viewing barcode regexes requires the "Product Management" role to be granted in your user 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 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 user 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 possible 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 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.

To add a barcode regex,

  1. Select "Add Barcode Regex" in the top left of the barcode regex page.

  2.  Enter a Name, if desired.
  3.  Enter a RegEx.
  4.  Enter an Expiration Date Formation, if the regex is parsing expiration dates.
  5.  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 user record. Contact your system administrator to add this capability.

There are two options for editing a barcode regex.

Option 1

  1. On the barcode regex page, open the quick action menu for the barcode regex you wish to edit and select "Edit"

  2. In the Edit Barcode Regex window that opens, make any desired changes.
  3. 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

  1. On the barcode regex page, click the barcode regex name link.

  2. In the Barcode Regex details page, make any desired changes.
  3. Click "Save Changes" to save the edited record. To cancel your edits, simply leave the barcode regex details page without saving.

Deleting Barcode Regexes

Deleting barcode regexes requires the "Product Management" role to be granted in your user 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 item's that may have utilized the barcode regex when they were added.

Option 1

  1. On the barcode regex page, open the quick action menu for the barcode regex you wish to delete and select "Delete"

  2. 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

  1. On the barcode regex page, click the barcode regex name of the barcode regex you wish to delete.

  2. On the barcode regex details page that opens, scroll to the bottom of the page and click "Delete".
  3. 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 doe 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 for more information, or use 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.