September 10, 2020 8 min read

Validating Question Answers Using Regex

Validating Question Answers Using Regex

Now validate secondary scans, multiple choice answers, and text entries to collect accurate data using the CodeREADr no-code/low-code SaaS platform

We help customers improve the accuracy of their collected data. This is one of many initiatives for achieving that goal. Read more about accurate barcode scanning app.

Periodically, we will share with our users Custom On-Device Validation (COV) scripts that we have created at a client’s request. One of our latest additions is a script for validating question answers using RegEx. Using this script, look for a designated pattern in data, such as a barcode scan, text entry, or text selection. Here is a link to all current COV scripts. Below are the instructions for validating question answers using RegEx.

CATEGORIES

Asset Tracking

Delivery Tracking

Inventory Audit

Process Tracking

Track & Trace

Warehouse Operations

Wholesale Ordering

SOCIAL SHARE

[fusion_sharing layout_small=”stacked” layout=”floated” tagline_visibility=”hide” tagline=”Share This Story, Choose Your Platform!” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” sticky_display=”normal,sticky” margin_top=”0″ margin_left=”0″ wrapper_padding_top=”0″ wrapper_padding_left=”0″ backgroundcolor=”rgba(255,255,255,0)” border_color=”#cccccc” stacked_align_small=”center” stacked_align=”flex-start” alignment_small=”space-between” alignment=”flex-start” icons_boxed=”yes” color_type=”custom” icon_colors=”#ffffff” box_colors=”#1a1a1a” tagline_placement=”after” separator_border_sizes=”0″ separator_border_color=”#cccccc” animation_direction=”left” animation_speed=”0.3″ /]

Step 1: Create a service

Create a service and collect data with questions as desired. The service must be on-device, not online.

service with questions

Note the question ID(s) for the questions you will be validating.

Question ID

Step 2: Advanced Settings

On the advanced settings step, select “Enable on-device custom validation.” In the text box, you will copy and paste this script.

pasted script

Step 3: Edit the script

Edit the script so that var regex includes only the patterns you would like to use. New additions to the array should follow the following format:

“QUESTION_ID”: [new RegExp(“PATTERN”), “OPTIONAL ERROR MESSAGE”]

For example, if you want to validate that your question answer contains the string “abc”:

“1737556”: [new RegExp(“[sS]*abc[sS]*”), “This ID is not valid.”]

regex patterns

This COV script has a wide variety of uses from secondary ID validation to enabling proper procedures and protocol. Any RegEx pattern can be used to authenticate the given question answer. If you have trouble implementing this script or are unsure if it would work for your use case, contact us via email or LiveChat.

RECENT POSTS