Couple of questions regarding regex expressions. Do they have to be applied
to 'TEXT' questions or can they also be applied to 'INTEGER' type questions
I am using the following epression to limit integers to maximum of 3,
although the expression works on regex check sites it doesn't limit how
numbers can be input. Any suggestions?
I would try .<4 as a validation condition or .<4 and .>-1
I'm not sure this is the precise syntax. But I think this approach is the
right one.
Simon
···
On Sun, Feb 5, 2017 at 3:27 AM, William Elson wrote:
Couple of questions regarding regex expressions. Do they have to be
applied to 'TEXT' questions or can they also be applied to 'INTEGER' type
questions
I am using the following epression to limit integers to maximum of 3,
although the expression works on regex check sites it doesn't limit how
numbers can be input. Any suggestions?
You can try including string-length(.) < 4 in your expression
Jeremy
···
On Saturday, February 4, 2017 at 11:53:51 PM UTC-5, Simon Berry wrote:
>
> I would try .<4 as a validation condition or .<4 and .>-1
>
> I'm not sure this is the precise syntax. But I think this approach is the
> right one.
>
> Simon
>
> On Sun, Feb 5, 2017 at 3:27 AM, William Elson <willia...@gmail.com > wrote:
>
>> Couple of questions regarding regex expressions. Do they have to be
>> applied to 'TEXT' questions or can they also be applied to 'INTEGER' type
>> questions
>>
>> I am using the following epression to limit integers to maximum of 3,
>> although the expression works on regex check sites it doesn't limit how
>> numbers can be input. Any suggestions?
>>
>>
>> regex(., '^[0-9]{1,3}')
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "commcare-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to commcare-user...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Please excuse any syntax errors. This email was sent from my phone.
> 07932 107109.
>
This Regular expression regex(., '^\d{4}$') ensures that you only input 4 digits(numbers), you can change it to the length you want e.g to limit to 3 integers use this regex(., '^\d{3}$') or you can use a much longer but easy to understand one regex(., '^[0-9][0-9][0-9]$') which only allows 3 integers. I hope i answered your question, right? If not, rephrase it, i may not have understood it well. cheers