Regex constraint to validate alphanumeric

I am trying to use RegEx to validate alphanumeric value.
Constraint = “regex(.,(’^[A-Z0-9]0[1-9]demogForm.xlsx (17.6 KB)

Can you describe or post some examples of what strings you are trying to check. Your regex looks like a valid regex expression, but without some test cases it’s not possible to determine if it’s fit for purpose. Thnx

I would like to check alphanumeric character ranges.
a) 001-999 Or.
b) A01-A99

regex(., ‘^[0-9]{3}$’)

regex(., ‘^[A-Z][0-9]{2}$’)

(assuming you want to allow prefix letters other than ‘A’) :slight_smile:

I highly recommend hopping on somewhere like and playing around. It’s simple to try out different regex expressions against data you type in, and finding out in real-time what does/not work is a great way to learn the seemingly indecipherable language of regular expressions.

Thanks Xiphware for your help.

I wanted to validate number with combination of alphabet with regex(., ‘^[A-Z][0-9]{2}$’). But throws error while converting through application designer.
“Error: Error: Unexpected token . interpretting formula: regex(., ‘^[A-Z][0-9]{2}$’) on sheet: survey row: 17 column: constraint”

Then after I changed regex to regex(’.’, ‘^[A-Z][0-9]{2}$’) it converted successfully.
But when I tried to preview the survey screen it throws error: Exception while evaluating constraint() expression. See console log.
The console log shows:
E/Exception: ‘regex is not defined’ in user-defined expression: regex(’.’, ‘^[A-Z][0-9]{2}$’) on survey row 17 column: constraint

Sorry, my response was wrt ODK1. But I now assume you are in fact using ODK2?

For ODK2, see Problem in Implementation of Regular Expression: ODK2.0 for a way to perform regex tests.

Thanks Xiphware for this one.