Not allowed value in regex

Friends, may I know what is wrong with this expression?
regex(., ‘^(1015544801|1015544802|1015544803|1015544804|1015544805|1015544806|1015544807|1015544808|1015544809|10155448010|10155448011|10155448012|10155448013|10155448014|10155448015|10155448016|10155448017)$’)
It only allows values in the bold areas ie 1-9 but values 10-17 is Not allowed. What should I do or is there a simpler way around this?

Could you check the regex behaviour, please, if you

  • remove the first number 1015544801
  • only use one of the problem numbers, e.g. 10155448017.

Design hint:
Even despite the limit of 9 digits for an integer type in Kobo Collect (but 16 in Enketo!), It might be possible to use a (numeric) constraint here:
(. >= 1015544801 and . <= 1015544809) or (. >= 10155448010 and . <= 10155448017)
(If needed you might cast a text to number(.), see ODK XForms Specification).

For the limits for numeric tyes see Number, Decimal and Range Question Types — KoboToolbox documentation

1 Like

I meanwhile tested with Enketo and your original regex works well (with text type and with integer type.). A shorter version would be: regex(., ‘^(101554480[1-9]|1015544801[0-7])$’)

A corresponding numeric constraint would be:
(. >= 1015544801 and . <= 1015544809) or (. >= 10155448010 and . <= 10155448017).

Hint: Your number sequence system seems special: Normally after 1015544809 would follow 1015544810 (not 10155448010). Or it would be 10155448009 and than 10155448010.

If you “concatenate” numbers, prefer mathematical calculation, to get 0 padding and a fixed format, e.g. ID (5 digits) = householdNo (3 digits) * 100 + personNo (2 digits).

1 Like

Thank you so much for the information. It was very useful and helped in resolution of a subsequent potential problem.

1 Like