Regular patter to zeros before digits like 001

Hi All,

I face some issue with regular expression patter in ODK, as it doesn't
accept any patter to this format "001", I read some posts that it doesn't
count zeros before any other digit although it works well if the patter is
all zeros like regex(.,'^[0][0][0][0]') , however this
"regex(.,'^[0][0]\d{1}$') or regex(.,'^[0]\d{2}$') or regex(.,'^\d{3}$')".

Any thoughts on this would be very appreciated.

Thanks,
-Hanan

To use regex() and handle leading zeros, the field type must be string.

If the field type is integer (or decimal), the string, as entered, is
converted first to an integer or decimal value, and then, if the constraint
specifies a regex(), that internal value is formatted as a string (dropping
all leading zeros), and then that string is evaluated in the regex().

··· On Tue, Aug 18, 2015 at 2:18 AM, Hanan Aqilan wrote:

Hi All,

I face some issue with regular expression patter in ODK, as it doesn't
accept any patter to this format "001", I read some posts that it doesn't
count zeros before any other digit although it works well if the patter is
all zeros like regex(.,'^[0][0][0][0]') , however this
"regex(.,'^[0][0]\d{1}$') or regex(.,'^[0]\d{2}$') or regex(.,'^\d{3}$')".

Any thoughts on this would be very appreciated.

Thanks,
-Hanan

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Yippe Yip, it worked, thanks for your help Mitch.

I just wanted to share, so others can benefit from this post, this is how I
fixed it followin Mitch's solution:

type name label::english hint::english appearance required constraint
constraint_message::english text child.id Child Id: The child number has
to be 3 digits format ex: 001 numbers yes regex(.,'[0-9][0-9][0-9]') or
regex(.,'[0][0-9][0-9]') or regex(.,'[0][0][0-9]')
The child number has
to be 3 digits format ex: 001

Thanks Mitch.

-Hanan

··· On Tuesday, August 18, 2015 at 12:18:41 PM UTC+3, Hanan Aqilan wrote: > > Hi All, > > I face some issue with regular expression patter in ODK, as it doesn't > accept any patter to this format "001", I read some posts that it doesn't > count zeros before any other digit although it works well if the patter is > all zeros like regex(.,'^[0][0][0][0]') , however this > "regex(.,'^[0][0]\d{1}$') or regex(.,'^[0]\d{2}$') or regex(.,'^\d{3}$')". > > Any thoughts on this would be very appreciated. > > Thanks, > -Hanan >

Thanks Yaw!

The secret key lies in the type of the data which has to be text, otherwise
it will never work even if we used the right pattern.

··· On Tuesday, August 18, 2015 at 12:18:41 PM UTC+3, Hanan Aqilan wrote: > > Hi All, > > I face some issue with regular expression patter in ODK, as it doesn't > accept any patter to this format "001", I read some posts that it doesn't > count zeros before any other digit although it works well if the patter is > all zeros like regex(.,'^[0][0][0][0]') , however this > "regex(.,'^[0][0]\d{1}$') or regex(.,'^[0]\d{2}$') or regex(.,'^\d{3}$')". > > Any thoughts on this would be very appreciated. > > Thanks, > -Hanan >

Hanan,

Pretty sure all you need in the constraint is regex(.,'[0-9][0-9][0-9]')

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Wed, Aug 19, 2015 at 2:47 AM, Hanan Aqilan hjameelq@gmail.com wrote:

Yippe Yip, it worked, thanks for your help Mitch.

I just wanted to share, so others can benefit from this post, this is how I
fixed it followin Mitch's solution:

type name label::english hint::english appearance required constraint
constraint_message::english
text child.id Child Id: The child number has to be 3 digits format ex: 001
numbers yes regex(.,'[0-9][0-9][0-9]') or regex(.,'[0][0-9][0-9]') or
regex(.,'[0][0][0-9]') The child number has to be 3 digits format ex: 001

Thanks Mitch.

-Hanan

On Tuesday, August 18, 2015 at 12:18:41 PM UTC+3, Hanan Aqilan wrote:

Hi All,

I face some issue with regular expression patter in ODK, as it doesn't
accept any patter to this format "001", I read some posts that it doesn't
count zeros before any other digit although it works well if the patter is
all zeros like regex(.,'^[0][0][0][0]') , however this
"regex(.,'^[0][0]\d{1}$') or regex(.,'^[0]\d{2}$') or regex(.,'^\d{3}$')".

Any thoughts on this would be very appreciated.

Thanks,
-Hanan

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.