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
Jagadesh BandaruJagadesh Bandaru 

regex for string validation

Hi,

I have to create a validation rule so that it will check the following conditions against:
1. The Length >2
2. Length<=20
3. It can only contain 2 alphabets (in any position).

This is what I wrote:
OR(LEN(abc__c)>20,LEN(abc__c)<3,    Not( REGEX(abc__c,".2[a-zA-Z].2"))), which is not working.

Any help would be appreciated.

Regards,
Jagadesh
Ayush TripathiAyush Tripathi
The  regex for only 2 alphabets can be written like this [0-9]*[A-Za-z][0-9]*[A-Za-z][0-9]*
RD@SFRD@SF
Hi Jagadesh,

I try this regular expression, I am able to get what you need. If needed you can play around with this and get to what you want.
 
NOT(REGEX(Name,"[0-9]*[A-za-z][0-9]*[A-Za-z][0-9]*"))

Hope it helps
RD​