For a study I am doing everyone gets assigned a unique number. All unique numbers are divisble by 11 (this is done because it makes sequential numbers quite different from each other).
I would ideally like a regex which I can use to check that the number entered in the study_id field is an acceptable value - e.g divisible by 11. I will have leading zeroes to a maximum of 5 digits So:
Any suggestions gratefully received
This isn't possible because there are no textual similarities between numbers that are divisible by 11
. Regex is used for text matching.
For example 000165
is divisible by 11
as is 00011
.
The best way to validate the number is to divide it by 11 and see if there is any remainder. So in Excel you'd do this:
=IF(MOD(165, 11) = 0, "VALID", "INVALID")
Or C# you'd do something like this
bool isValid = 165 % 11 == 0;
(Disclaimer I'm not familiar with ODK so I can't provide a suitable sample; I've just guessed on the best language to write in)