# Barcode Scanner Input breaking Regex(ALL) into Single Characters

**URL:** <https://forum.inductiveautomation.com/t/barcode-scanner-input-breaking-regex-all-into-single-characters/58611>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [April 19, 2022, 9:17pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner-input-breaking-regex-all-into-single-characters/58611 "2022-04-19T21:17:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dominicfabiilli](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dominicfabiilli](https://forum.inductiveautomation.com/u/dominicfabiilli)\
**Post date:** [April 19, 2022, 9:17pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner-input-breaking-regex-all-into-single-characters/58611/1 "2022-04-19T21:17:28Z")

</div>

(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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/2/c252defdb9568358dc5c93fdfccc34b781c174a6.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/e/eef424b9987f07b8b9e908999567ebc172b43385.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 19, 2022, 9:28pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner-input-breaking-regex-all-into-single-characters/58611/2 "2022-04-19T21:28:33Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![dominicfabiilli](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dominicfabiilli](https://forum.inductiveautomation.com/u/dominicfabiilli)\
**Post date:** [April 20, 2022, 12:23pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner-input-breaking-regex-all-into-single-characters/58611/3 "2022-04-20T12:23:09Z")

</div>

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.

> **[regex101: build, test, and debug regex](https://regex101.com/)**
>
> Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/3/33c86e962cc8252474b98ea7c2329ea10ce24333.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 20, 2022, 1:08pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner-input-breaking-regex-all-into-single-characters/58611/4 "2022-04-20T13:08:09Z")

</div>

> [@dominicfabiilli](#):
>
> what is the best way to capture that in perspective?

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.

> [@dominicfabiilli](#):
>
> I tested the same syntax on a regex interpreter and it returned the full scan as 1 group, with no missed characters.

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.
