Barcode Scanner Input & RegEx

Hi,

i need to recognize a barcode using the Barcode Scanner Input.

I need to recognize codes like:

  • H1
  • H21
  • D1
  • D5
  • P1
  • P12

The follow RegEx doesn't work as aspected.

([HDP]\d{1,}){1}

It recognize the First Letter and only the First Number so the "H1" and the "H12" return only H1..
I tried a lot of RegEx but with not success...

What i'm doing wrong?

I would expect a regex of ([HDP]\d+) to work.

No, it doesn’t work. I already tried a lot of time… It return only First Letter and First Digit… :smiling_face_with_tear:

Ah. Try this: ([HDP]\d+)Enter

The regex match is returning as soon as the first match is found, not waiting for more input. If your scanner is configured to terminate the scan with a keypress of Enter, you can capture that (outside of the group) and it will work:
image

To solve this problem at the moment i added a PREFIX and SUFFIX in Scanner Data Output like:

  • pre: @
  • suf: #

The RegEx work in this case…

If you’re using prefix or suffix, the regex property is ignored. If your barcodes end in #, you could use that with the updated regex I posted above, just replace Enter with #.

1 Like