Skip to content
English
  • There are no suggestions because the search field is empty.

Regular expression: what is it and how to use it?

Is the app scanning/reading more than that you want it to scan? Make the Cargosnap scanner smarter by defining a specific format.

What is a Regular Exppression?

A regular expression (also known as regex) is a sequence of characters that specifies a match pattern in the text.

For example: the field that you want to scan is an Order Number, which is not barcoded. 

Very often, on the same paper as where the order number is printed, there is a lot more information to be found. The scanner - in all its enthusiasm - might read more than just the Order number, giving you an "incorrect" unique reference.

How does it work?

A regular expression is constructed by the following parts: [A-Z]{n}\d{n} ("n" stands for a number). To further explain these characters one by one:

  • [A-Z] matches a string of Capitalised letters from A-Z, for example, YRHA or OSN.

  • {n} matches how many letters does this string have. So, if it's [A-Z]{2}, that means there are two Capitalized letters, for example, MA, CB, etc.

  • \d{n} matches how many numbers (digits) are there. So if it's \d{6}, that means there are 6 numbers in total, as an example, 864258.

Let's practice

  • If your reference or seal number consists of simply a series of numbers:

    For example, 004188, the regular expression is \d{6}.

  • If your reference or seal number consists of several Capitalized letters and a series of numbers:

  • For example, MA46678, the regular expression is [A-Z]{2}\d{6}. Another example is ESCA30522, its regular expression is [A-Z]{4}\d{5}

Online there are many available AI tools to set up your regular expression in a second. Need some help? Reach out to our support team.

How to set it up in a Workflow?

You can use the regular expression only in the Container Seal to either scan text (OCR) or a Barcode.

Simply create a new 'Seal' field and fill in the Regular Expression.

More information about the regular expression and the seal scanner in this article.