Problems with regex expression in calculate field

What is the problem? Please be detailed.
I'm trying to extract a string of 5 characters into a calculate field using if and regex, however the result of the if statement is always 0.

The string of 5 characters is captured from a barcode and always in the format "AB1245" and includes the double speech marks. The if statement with regex to select the 5 characters between the two double speech marks in a calculate field pid2 is as follows:


In the online regex tool, the regex expression appears to work. But for some reason it fails in ODK. Any thoughts on where this might not be working?

What ODK tool and version are you using? And on what device and operating system version?
ODK Collect v1.12.2

What steps can we take to reproduce the problem?

What you have you tried to fix the problem?
Searched online,

Anything else we should know or have? If you have a test form or screenshots or logs, attach here.

I've run into issues with \d in other regular expression engines. Maybe try replacing it with [0-9]?

Regex performs a test and returns true or false, not the split value! In this case, since the token length is fixed you should be able to use substr (

1 Like

substr worked perfectly thanks!