# Perspective Barcode Scanner Input: Use multiple regex on same component

**URL:** <https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350>\
**Category:** Ignition\
**Tags:** vision, ignition81, perspective\
**Created:** [June 29, 2022, 1:44pm UTC](https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350 "2022-06-29T13:44:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 29, 2022, 1:44pm UTC](https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350/1 "2022-06-29T13:44:45Z")

</div>

I’m used to the Sepasoft barcode scanner component in Vision where I have multiple named regex patterns on a single component. For example, my session will need to scan different barcode formats and run a script according to the barcode type. The only way I can think of mimicking this behavior is to handle the regex processing inside an event script and not the regex property. Is that right?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 29, 2022, 3:28pm UTC](https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350/2 "2022-06-29T15:28:03Z")

</div>

I think I will have to do this in scripting.

Also, how can I use a carriage return for the suffix? (0x0d)

---

<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:** [June 29, 2022, 3:44pm UTC](https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350/3 "2022-06-29T15:44:19Z")

</div>

I think you do have you use scripting, yes. If you're using key event scripts to capture, then note that the regex is being run on the frontend, and there's some... weird Javascript quirks as a result:

> [@Perspective Key Event Regex New Line](https://forum.inductiveautomation.com/t/perspective-key-event-regex-new-line/51553/7):
>
> Ugh, you’re right, there is something strange here. It seems that the regex is matching against some string representation of the typed key, not the actual underlying character. A regex like this works when you press enter: .+(Enter) [image]

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 29, 2022, 3:50pm UTC](https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350/4 "2022-06-29T15:50:11Z")

</div>

I’m using the scanner component, and applying my different regex’s in an `onActionPerformed` script. It works fine, I just want to make the suffix property a CR (0x0d) but just seems to take literal text.

---

<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:** [June 29, 2022, 3:50pm UTC](https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350/5 "2022-06-29T15:50:58Z")

</div>

I think you need to use an expression or script to populate with a literal, e.g. `\r`.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 29, 2022, 4:08pm UTC](https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350/6 "2022-06-29T16:08:05Z")

</div>

> [@paul-griffith](#):
>
> use an expression or script to populate with a litera

I guess you can't do that, I tried it without success.

---

<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:** [June 29, 2022, 4:18pm UTC](https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350/7 "2022-06-29T16:18:13Z")

</div>

It should work as long as you don’t try to manually edit it:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/2/c27c7d95e26ad8e05875d9efaa042af133fd3085.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cfc5e87cb8176a27247fa8aa6911bdf9fbacbb7e.png)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 29, 2022, 4:44pm UTC](https://forum.inductiveautomation.com/t/perspective-barcode-scanner-input-use-multiple-regex-on-same-component/61350/8 "2022-06-29T16:44:14Z")

</div>

I still couldn’t get it to work, but I think the regex is really the way to go. That way I don’t have to program prefixes or suffixes. You can apply multiple regexes with `|` although that doesn’t tell you which pattern matched in the script, but that can be handled inside the script. Thanks!
