Trying to parse a string read from a barcode

1. What is the issue? Please be detailed.
I am scanning a barcode the name of the field is "barcode".
The output is a string in this form aaa|ssd fff vvv|a|err|1234567890|3356

I want to pass the individual regex matches into separate fields

2. What steps can we take to reproduce this issue?

3. What have you tried to fix the issue?
This is what I have done so far:

  1. In another field using calculate I have used regex(${barcode},('[^|]+')
    the idea is to pull aaa into this field
    then pull ssd fff vvv into another field

  2. I have tested the regex in

  3. I was expecting "true" as regex results in true or false

The next step would be to get the actual string match - not sure how as of yet

I would appreciate any ideas on this.

4. Upload any forms or screenshots you can share publicly below.

Try this:
parsebarcode.xlsx (9.3 KB)

Basically, it converts your '|' delimited string into a space-separated one, allowing you to then use selected-at() to extract each field. Once each field is extracted you can perform whatever further calculations and/or field-specific validation checks you wish on them individually. Note: in order to preserve the original spaces appearing in the second field, you have to translate them into something else and back again; you will have to likewise do this for any fields that can potentially contain spaces.

If you like, replace the above ${barcode} text question with an actual barcode one to scan the string in.

1 Like

Thanks @Xiphware, this works perfectly.