constraining input with regex not working with .0

503
2
Jump to solution
04-02-2019 07:48 AM
MikeOnzay
Occasional Contributor III

I want to constrain the input of a number that is 1-7 numbers, a decimal point, and one number after the decimal point. If the number after the decimal point is zero it doesn't validate.

I've tried 

regex(.,'^\d{1,7}\.\d{1}$')

regex(.,'^[0-9]{1,7}\.[0-9]{1}$')

123.0 - invalid

1234567.9 - valid

1.0 - invalid 

1.1 - valid 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Mike,

I am able to use your second function with a text question for all the examples you provided.  A decimal question also validated all but the '123.0' test case - this is because it would be stored as 123

View solution in original post

0 Kudos
2 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Mike,

I am able to use your second function with a text question for all the examples you provided.  A decimal question also validated all but the '123.0' test case - this is because it would be stored as 123

0 Kudos
MikeOnzay
Occasional Contributor III

I had the type set to decimal. When I set it to text the regex worked. I adjusted my formulas to convert the value to number and the output is what I would expect to see.

0 Kudos