What is Pattern Matching in Validation?
Pattern matching is a powerful feature that allows you to define how an app responds to barcode scans that fit a specific “pattern.” Patterns are defined based on the following elements:
- Length: Barcodes must match the specified length.
- Required Characters: Barcodes must match the exact positions of letters, numbers, or symbols defined in the pattern.
- Wildcards: Barcodes can contain any character in positions marked by the ? symbol.
Example Pattern:
If the pattern is F767-??????, any barcode starting with F767- and followed by six characters will match.
Code | Match |
---|---|
F767-abc123 | matches |
F767-ABC!@# | matches |
F 67 7-abc123 | does not match: the 7 and 6 are in the wrong position. |
F767-abc123 4 | does not match: too many characters |
f 767-abc123 | does not match: one of the required characters is in the incorrect case |

Pattern Validation and Duplicate Checking Options
When creating a ‘Validate Scans’ service, you can choose from two primary options:
- Apply a Validation Pattern:
- Enable this option to validate scanned barcodes against a predefined pattern. Benefits include:
- Easily add unrecognized barcode values to the database.
- Force an invalid response for specific matches, e.g., discontinued items.
- Enable this option to validate scanned barcodes against a predefined pattern. Benefits include:
- Standard Validation Service:
- If you don’t use a validation pattern, configure your service using the Alter Scan Value feature to process scan values.
Key Use Cases for Validation Patterns
Validation patterns allow you to manage scans effectively without requiring a complete database. Common use cases include:
- Ticket Sales: Validate and detect duplicate ticket scans without uploading ticket IDs.
- Privacy Concerns: Avoid uploading sensitive databases (e.g., student or patient IDs).
- Large Databases: Manage extensive databases like coupon IDs more efficiently.
- Offline Support: Store scanned values on the device to check for duplicates and provide reporting.
Setting Up a Validation Pattern Matching Service

Follow these steps to configure a validation pattern:
- Create or Edit a Validation Service:
- Start by creating a new validation service or modifying an existing one.
- Enable Pattern Matching:
- Check the ‘Apply a Validation Pattern’ box to access pattern settings.
- Define Your Pattern:
- Use characters and the wildcard ? to specify your desired pattern.
- Set a Response Message:
- Enter the message to display when the scanned barcode matches the pattern.
- Optional: Add Values to Database:
- Check the box ‘Add scanned value and response to the database when a match is made’ to save barcodes and their validation status.
- Save Your Configuration:
- Click ‘Save and Continue’ to apply the settings.
Note: To enable duplicate scanning detection, ensure that scanned values are 100 characters or fewer. Use the Alter Scan Value feature to truncate longer values if needed.
Advanced Setup Notes
- Pattern Matching Without a Database:
- Upload a database to validate barcodes against existing entries.
- If no match is found, the barcode is validated against the pattern.
- Force Invalid Responses:
- Check the ‘Force an invalid response when a scan match is made’ box to flag specific values, such as expired tickets or discontinued items.
- Wildcard Patterns for Unknown Formats:
- Use ? for each position to save unknown barcode values to the database.
- Leave the Code Pattern field empty for variable-length barcodes.
Using Regular Expressions (Regex) in Validation Patterns
You can enhance validation patterns with regex to allow more complex matching scenarios. Check the ‘Use Regular Expression’ box and input your regex script.
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.
Why Choose Validation Pattern Matching?
Validation patterns streamline barcode scanning workflows, ensuring accuracy and flexibility for various use cases. Whether handling privacy-sensitive data, managing large datasets, or enabling offline operations, pattern matching simplifies validation while offering advanced customization with regex.