A field should accept numbers between 1-100 including decimal.

akhila13
Tera Expert

A field should accept numbers between 1-100 including decimal. Can anyone share the regular expression for this

7 REPLIES 7

Hello,

 

Use the below regex I tested it out woks correct:-

 

^([1-9][1-9]{0,2}|100)(\.\d{1,2})?$
 

Please mark answer correct/helpful based on Impact.

Mahendra RC
Mega Sage

Hello @akhila13 

If you want to allow 01.00, 02.33, 09.03 .. till 100.00 numbers as valid then use below regex:

^[0]{1}[1-9]{1}(\.[0-9]{1,2})?$|^[1-9]{1,2}(\.[0-9]{1,2})?$|^(100)(\.[0]{1,2})?$

 

if you 1.00, 2.33, 9.03 .. till 100.00 numbers as valid but 01.00, 02.33 (i.e number starting with 0) as invalid then use the below regex

^[1-9]{1,2}(\.[0-9]{1,2})?$|^(100)(\.[0]{1,2})?$

H_9
Giga Guru

Hi Akhila,
You can use the below regex, it will work:

 

^(?<whole>100|\d{1,2})(?<fract>\.\d{1,8})?$

 

Please mark the answer correct if it helps. 🙂

Thanks. 🙂