constraining input with regex not working with .0

91
2
Jump to solution
04-02-2019 07:48 AM
Highlighted
Regular Contributor

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)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
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

Reply
0 Kudos
2 Replies
Highlighted
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

Reply
0 Kudos
Highlighted
Regular Contributor

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.

Reply
0 Kudos