Regular Expressions in the constraint field

Hi Everyone,
Does anyone have experience using the regular expressions in the constraint
field?

I want to allow a decimal between the values 60.0 and 150.0 inclusive.

the field type I want to use is a decimal.

The problem is that however odk handles regular expressions it doesnt seem
to allow for a "0" to follow a decimal.
Everything else seems fine.

I have tried this regular expression elswhere and it works:
http://www.regexplanet.com/advanced/java/index.html

I have tried using this inside the constraint field of my.xls file:
regex(.,'^[0-9][0-9].[0-9]|[0-9][0-9][0-9].[0-9]$')

it does not allow 60.0,61.0,62.0,63.0 etc. where it actually should.

Does anyone have any suggestions?

Thanks,
Brian

Brian Dyer

IT Specialist

Johns Hopkins School of Public Health

Department of International Health

615 N Wolfe Street Rm E3143

Baltimore, MD 21205 USA

(443) 287-8784

Hey Brian,

There is a bug in the regex with leading zeros (see
https://groups.google.com/group/opendatakit/browse_thread/thread/798ac40e2be6c9ba/
and http://code.google.com/p/opendatakit/issues/detail?id=546).

In this particular case, it might be simpler just to use a normal constraint.

constraint=". >= 60.0 and . <= 150.0"

Yaw

ยทยทยท On Mon, Aug 6, 2012 at 5:19 AM, Brian Dyer wrote: > Hi Everyone, > Does anyone have experience using the regular expressions in the constraint > field? > > I want to allow a decimal between the values 60.0 and 150.0 inclusive. > > the field type I want to use is a decimal. > > The problem is that however odk handles regular expressions it doesnt seem > to allow for a "0" to follow a decimal. > Everything else seems fine. > > I have tried this regular expression elswhere and it works: > http://www.regexplanet.com/advanced/java/index.html > > > I have tried using this inside the constraint field of my.xls file: > regex(.,'^[0-9][0-9]\.[0-9]|[0-9][0-9][0-9]\.[0-9]$') > > it does not allow 60.0,61.0,62.0,63.0 etc. where it actually should. > > Does anyone have any suggestions? > > > Thanks, > Brian > > > Brian Dyer > > IT Specialist > > Johns Hopkins School of Public Health > > Department of International Health > > 615 N Wolfe Street Rm E3143 > > Baltimore, MD 21205 USA > > (443) 287-8784 > > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en