All Collections
The Cargosnap app
Regular expression: what is it and how to use it?
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.

Updated over a week ago

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

For example: your unique reference is an Order number, which is not barcoded. Therefore, you most likely use in the Cargosnap app the 'Text and Number' scanner to scan your order number.

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

To ensure the scanner scans the correct reference, we created a feature to set your own regular expression via the 'reference warning'

How to set it up?

You have 3 options, depending on your own use case:

  1. You configure it so it matches a specific number of digits

  2. You use a container code

  3. Regular expression (advanced).

When using the container number scanner as your top widget, you won't need an extra reference warning as it's already integrated into the container number widget.

Let's dive a little bit deeper into option 3 as this option enables you to customize your own regular expression.

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 now use some examples to put it into 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}

Note: do not contain any space at the beginning nor the end.

Hope this makes sense! Feel free to give it a try yourself, and if it doesn't work out for you, no worries. You can always get quick help by clicking the orange chat window in the bottom right corner. Send us a couple of images of such cases. We may be able to tweak your configuration! 😉

Did this answer your question?