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
Victor19Victor19 

REGEX Validation Rule

I need help writing a REGEX Validation rule.

 

Condition:

                  Filed Name - TestNo

                  Field length  - 23 characters

                   No of values in the field - 4 values with 5 characters (only numbers) seperated by commas.

                  Eg: 12345,23456,12356,23456

 

I need a validation rule that makes sure the TestNo(s) are 5 digits and separated by commas with no spaces

 

Can someone help me in building a formula using REGEX or some other function.

imutsavimutsav
Try this
NOT( OR( LEN (TestNo) = 0, REGEX(TestNo, "[0-9]{5},[0-9]{5},[0-9]{5},[0-9]{5}") ) )
Victor19Victor19

Hi imutsav,

 

I tried out your VR. It is still not working.

Victor19Victor19

We have a similar VR setup for an other field, but this field has alphanumberic values and has 4 characters in each value separated by commas.

 

IF(ISBLANK(Facets_Grp_Num__c), FALSE,
NOT(REGEX(Facets_Grp_Num__c, "[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9](,[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]){0,10}")))

 

Anyway I can change this and used it for my condition strictly numeric with 5 characters in each value?

Felipe Justino Linhares 3Felipe Justino Linhares 3
OR(
    NOT(REGEX(TestNo,"([0-9]{5}([,]?))+")),
    REGEX(RIGHT(TestNo,1),"[,]"),
    NOT(LEN (TestNo) = 23)
)