Hi,

I am trying to do a regex constraint on a field of type "decimal".

The regex is the following: regex(.,'^[+-]?[0-9]{1,2}\.[05]$')

What this says is that i want a number to looks like this: 10.5 or 6.0 etc..

The problem is that the regex evaluate to false when i place a 0 at the decimal. It correctly evaluate to true if the decimal is a 5.

If I use a field of type "text" the regex correctly understand the decimal 0 or 5, so the regex expression is correct. It seems to be a problem with fields of type "decimal".

Is there anyway to solve this? Is it possible to parse the number to text before evaluating it with the regex?

EDIT:

Ok this regex seems to work: regex(.+"",'^[+-]?[0-9]{1,2}(\.[05]{1})?$')

But somehow both regex I used allow for 10. or 5. for exemple (a number without any decimal)

Hi Nicolas,

Just to be clear, you are trying to constrain values to either be whole numbers or whole and a half? It might be easier to have a mathematical constraint - one way is to multiply by 10 and then check for a remainder using modulo:

(.*10) mod 5 = 0