Barcode Scanner Input breaking Regex(ALL) into Single Characters

(I am using Ignition 8.1.15.)

I want to make a Barcode Scanner Input component with Regex “(.*){1}” to accept any scan.
However, this does not keep the string as one element in the array (see the two images).
Also, multiple characters are getting missed with no consistency to location or number of missed characters.
Any ideas?

image
image

The star * suffix on a match means zero or more of the preceding element, which for you is a single wildcard. It can match on empty strings, single characters, or many characters. You need a match that is unambiguous–usually with leading and trailing delimiters that won’t be typed or be part of the scan. The {1} suffix is utterly useless (redundant).

ok, fair point. but one of my customer’s barcodes can be any format. what is the best way to capture that in perspective?

I tested the same syntax on a regex interpreter and it returned the full scan as 1 group, with no missed characters.

I think the only reliable way is going to be the barcode scan action with a native scanner. (I gather this is not a native scanner in the mobile app.) See if your scanner can add delimiters before and after the scan, and include those in your regex.

Yes, but you supplied the scan in one go, right? A real scanner acting as a keyboard is going to supply the scan one character at a time. Try mimic'ing that in your regex interpreter. You need a regex that won't match until the entire scan is present.

1 Like