Binding Xlsform regex to questions

342 Views Asked by At

I am designing an ODK survey form using XlsForm. On this form I have set some regex constrains that have pretty much the same structure except for some parts that are different. For example regex(.,'^farmer-[mM][aA][dD][fF][aA][iI]-\d{5}$'). I have used something similiar regex(.,'^[mM][aA][dD][fF][aA][iI]-\d{5}$') as a constraint on another question. What I want to achieve is How to reuse or bind the expression by setting it in one place and only referencing it in different questions. Any help is very much appreciated. Thank you

1

There are 1 best solutions below

0
On

You can do this by creating a type=calculate that stores the regex and then refer to it in your questions when necessary. Make sure to put the calculation inside quotation marks.

enter image description here