^[A-Z]{2}\d{9}[A-Z]{2}$ Royal Mail Track & Trace code ^\d{16}$ visa card ^\d{13}$ EAN-13 barcode

It seems you are working with a barcode scanner. All barcode scanners I've seen so far can be configured to add prefixes or suffixes to indicate the type of barcode scanned. This could be used here. By enabling a barcode type prefix, you could better check for what has been scanned: A 13-digit number is just junk unless it is prefixed with the "this is a EAN barcode" prefix, in that case, it is really an EAN 13 barcode. If you see instead e.g. a Codabar prefix and a 13 digit number, whatever you scanned was not a EAN-13.

This works extremely well, I know this feature is used in blood banks to prevent misreadings of wrong labels.

The first manual I found (https://www.prosoft.ru/cms/f/426190.pdf) contains a long list of barcodes and identifier prefixes on page 25 (PDF page 26), one "AIM standard" ("]" + one upper case letter + one digit) and one "Datalogic Standard" (singe upper or lower case letter), and it suggests that you can reconfigure the codes.

The list shows several different identifiers for EAN, as you can have EANs in 8 or 13 digits, and they can have two different, mutual exlusive add-ons, resulting in six identifiers.

Another thing to consider is to configure the (USB) barcode scanner not to emulate a keyboard, but instead to present itself as a serial device. This prevents manual "scanning" by typing in data via the keyboard. The application that uses the scanner needs to be changed a little bit, but it avoids the largest source of errors: The human using the computer. As a nice side effect, it also avoids problems with Caps Lock, Num Lock, and non-US keyboard layouts.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re: Pattern Identification by afoken
in thread Pattern Identification by WhiteTraveller

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.