# Barcode scanner

**URL:** <https://forum.inductiveautomation.com/t/barcode-scanner/51121>\
**Category:** Ignition\
**Created:** [September 19, 2021, 11:25pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner/51121 "2021-09-19T23:25:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nii/32/12920_2.png) [@NII](https://forum.inductiveautomation.com/u/NII)\
**Post date:** [September 19, 2021, 11:25pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner/51121/1 "2021-09-19T23:25:57Z")

</div>

I have a couple of questions about barcode scanner component:

1 - What is the proper/correct entry for regex? Is the an example of it’s usage?

2 - An new array index is added on every scan, what is the max size limit of the array and what happen when it goes over the max?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 20, 2021, 3:20pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner/51121/2 "2021-09-20T15:20:16Z")

</div>

The regex is any regex - you decide what it 'should' be. Regular expressions are a common text-parsing scheme, allowing you to use a very terse syntax to explain conditions that would be complicated to 'write out' in actual code. For use in the barcode scanner component, you might want to, for instance, restrict your scanned input to match the format of your product codes, such as '3 digits, followed by a hyphen, followed by 5-8 alpha characters'. In regex, that's `^\d{3}-[a-zA-Z]{5,8}$`: [regex101: build, test, and debug regex](https://regex101.com/r/PsoPIZ/1)  
Your actual regex will vary depending on your requirements.

> [@NII](#):
>
> 2 - An new array index is added on every scan, what is the max size limit of the array and what happen when it goes over the max?

There is no explicit max size limit. You're in charge of truncating it, but it shouldn't be an issue unless you got into the thousands of scanned barcodes without changing pages.

---

<div class="post-metadata">

**Author:** ![NII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nii/32/12920_2.png) [@NII](https://forum.inductiveautomation.com/u/NII)\
**Post date:** [September 21, 2021, 5:28am UTC](https://forum.inductiveautomation.com/t/barcode-scanner/51121/3 "2021-09-21T05:28:02Z")

</div>

Thank You

---

<div class="post-metadata">

**Author:** ![andrewdhunt7](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@andrewdhunt7](https://forum.inductiveautomation.com/u/andrewdhunt7)\
**Post date:** [September 23, 2021, 9:52pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner/51121/4 "2021-09-23T21:52:47Z")

</div>

Maybe this is a silly question, but does the Barcode Scanner Input component require prefix and suffix in order to have values parsed through Regex? When we attempt to leave prefix and suffix blank and use the window length and regex expression to parse values, it does not log anything. We have verified with the tool above that the regex expression is valid. We don’t have any control over adding a prefix to the scans coming in from the customer

---

<div class="post-metadata">

**Author:** ![Thiru\_Medampalli](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thiru_medampalli/32/33619_2.png) [@Thiru\_Medampalli](https://forum.inductiveautomation.com/u/Thiru_Medampalli)\
**Post date:** [April 8, 2022, 11:22pm UTC](https://forum.inductiveautomation.com/t/barcode-scanner/51121/5 "2022-04-08T23:22:05Z")

</div>

prefix and suffix and regex are mutually exclusive i.e if you use prefix and suffix then regex won't be used if you leave those values empty then the given regex will be used.

If you want you can include the required prefix and suffix as part of the regex expression if you have one. If there is a predictable pattern then it is better to use the regex and no need to configure a prefix/suffix

Moreover, the format of the regex is not documented and the format that it needs to be surrounded by brackets and group number 1. i.e Format should be (regex){1}
