Article sections

    What is Pattern Matching?

    Validation Pattern matching enables users to specify how the app reacts to scans that match a “pattern”. The format of a pattern relies on three things:

    • Length: Barcodes must have the length of the pattern to match.
    • Required Characters: Barcodes must match positions in which there are letters, numbers, or symbols in the pattern.
    • Wildcards: Barcodes can have any character in the position where the symbol ? is placed.

    For example, if the pattern entered is F767-??????, any barcode that starts with the characters ‘F767-‘ and ends with any six characters will be valid.

    Here are some entries that would and would not match the pattern F767-??????:

    F767-abc123matches
    F767-ABC!@#matches
    F 67 7-abc123does not match: the 7 and 6 are in the wrong position.
    F767-abc123 4does not match: too many characters
    f 767-abc123does not match: one of the required characters is in the incorrect case
    Code Pattern

    What Options Are Available for Pattern Validation and Duplicate Checking?

    When creating a ‘Validate Scans’ service type, you have two options even without having a complete database to validate against.

    1. First, you can check the ‘Apply a Validation Pattern’ box. You can find the instructions below. The benefits of this option include a) the ability to easily add scanned values to the database if they are not already there; b) forcing an invalid response if there’s a match – for example, to indicate if an item is discontinued.
    2. Second, you can create a standard validation service. For example, don’t check the ‘Apply a Validation Pattern’ box. However, when creating your service, use the powerful Alter Scan Value feature.

    What Can I Do With Validation Patterns?

    You can catch invalid or duplicate IDs without a complete database residing on our servers.

    Use-cases include:

    • Sell tickets prior to an event without needing to upload the ticket IDs to codeREADr. In fact, you don’t need to upload the ticket IDs to catch duplicates.
    • Service providers don’t have to upload databases to our servers – whether for privacy concerns (e.g. student or patient IDs) or because the database is too large (e.g. coupon IDs).

    Once you scan, it stores the scanned ID either online or on the device to enable checking for duplicates and to provide reporting.

    How to Set Up a Validation Pattern Matching Service

    Validate with partial database
    1. Create a validation service, or edit one of your existing services.
    2. Click “Apply a Validation Pattern”. Then, a new section will appear.
    3. Using normal characters and the ? symbol, define a pattern.
    4. Enter a response to show the app user when the pattern is matched.
    5. [OPTIONAL] Checking the box ‘Add scanned value and response to the database when a match is made’ will add the scanned barcode, the pattern’s response, and its validity to the service’s database.
    6. Press ‘Save and Continue’ to save your changes and continue creating/updating your service.

    If you want to check for Duplicate scans, you need to check this box. However, the scanned value cannot be greater than 100 characters for this setting unless you use the Alter Scan Value feature (Example D) to limit the number of characters captured to 100 or less.

    Notes on Setup:

    You can use Pattern Matching with or without a validation database. First, if you upload a database to our servers, this service type will check if the barcode value is in the database. Then, if it is, it validates against that database. However, if it isn’t, it validates against the pattern.

    Also, if you check the box ‘Force an invalid response when a scan match is made’, you can alert the app user when certain barcode values need special attention. For example, you could alert them when they scan expired tickets or discontinued items.

    No Pattern? No Problem

    If your IDs don’t have a known pattern other than the number of characters in the ID, you can use the ? wildcard for every position to save the barcode value to the associated database. If you don’t have a known pattern and not all barcode values are the same length, leave the Code Pattern field empty. Then, anything you scan will be added to the database.

    Why would you use Scan Mask’s pattern validation without a pattern or even without an original validation database? Because it enables you to add barcode values to a database when you check the box ‘Add scanned value and response to the database when a match is made’. Thus, you can catch duplicate scans for both online and on-device database services.

    Using Regex with Validation Patterns

    You can use the Alter Scan Value option with regex. Also, for some configurations, you can do that here too. Simply check the box ‘Use Regular Expression’ and enter your script in the form field. To limit the number of characters captured you need to use the Alter Scan Value feature.

    Example A

    – Allow any number of alpha or numeric characters after the prefix ‘xx’ to be valid.

    ^({xx}{?})$

    Example  B

    – Allow only 5 digits to be valid.

    ^([0-9]{5})$

    Example C

    – Allow only 4 or 5 digits after a prefix ‘xx’ to be valid.

    ^xx([0-9]{4,5})$

    Example D

    – Allow only 8, 9, or 10, digits after a prefix ‘xx’ to be valid.

    ^xx([0-9]{8,10})$

    Example E

    – Allow only 5 digits after ‘xx’ or ‘XX’ to be valid.

    ^(xx|XX)([0-9]{5})$

    Example F

    – Allow only 8, 10, or 12 digits after a prefix ‘xx’ to be valid.

    ^xx([0-9]{8}|([0-9]{10})|([0-9]{12}))$

    Example G

    – Allow only MX or WX prefix with any number of alpha or numeric characters to be valid.

    ^(MX|WX)([\da-zA-Z]{1,})$

    Note: For Android OS devices in some cases you may need to escape the { } (curly braces) if used as a literal character. So, for example, you would use \{ and \} in the regex.

    in Services