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
Rakesh Kumar 378Rakesh Kumar 378 

Regex Trouble



Hi All,

I have a requirement where I need to check the format of a text field like DD/MM but we need to ensure that if we enter 02 as month then it should not allow to use any value above than 28. I am using the below mentioned validation rule and it checks every thing excep the feb month condition

AND( 
NOT(ISBLANK(EarliestStartDate__c)), 
NOT(REGEX( EarliestStartDate__c ,"(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])")) 
)

Kindly suggest
 
Alain CabonAlain Cabon
Hi,

28/02 is not correct as a limit. A leap year also needs 29/02 and the year but be included in the format.

Description: This expression is an improved version of Maag. It checks a date field in the Australian DD/MM/YYYY format.
Besides, it also validates leap year between 1900 and 2099.
Matches: 29/02/1992 | 29/02/2000 | 29/02/2004
Non-Matches: 29/02/1892 | 29/02/2100 | 29/02/3004
Author: Yik Kheam Tan

Rule Name: check_DD_M

Error Condition Formula:

REGEX( test_text__c ,"^(((((0[1-9])|(1\\d)|(2[0-8]))/((0[1-9])|(1[0-2])))|((31/((0[13578])|(1[02])))|((29|30)/((0[1,3-9])|(1[0-2])))))/((20[0-9][0-9]))|((((0[1-9])|(1\\d)|(2[0-8]))/((0[1-9])|(1[0-2])))|((31/((0[13578])|(1[02])))|((29|30)/((0[1,3-9])|(1[0-2])))))/((19[0-9][0-9]))|(29/02/20(([02468][048])|([13579][26])))|(29/02/19(([02468][048])|([13579][26]))))$")

http://regexlib.com/REDetails.aspx?regexp_id=708