function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ron-LONRon-LON 

validation Rule REGEX with decimals

Hi,

 

I'm looking to validate software version numbers to ensure they contain only one decimal and can be between

0 and 99.99.

 

At first I thought I could just use a number, but with versioning, 1.3 and 1.30 are different values.

 

I thought this should work:

 

REGEX( Version_Number__c, "(\\d){0,2}(\\.)(\\d){0,2}" )

 

It works for whole numbers, but fails once you add in a decimal point.

 

Any tips would be appreciated.

Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below Regex

REGEX =/^[1-9]\d{0,1}(\.\d{2})?$/;
This works fine for 0 to 99.99.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

Ron-LONRon-LON

If I put in 

 

REGEX( Version_Number__c, "/^[1-9]\d{0,1}(\.\d{2})?$/;")

 

I get "syntax error" back.