How to eliminate consecutive two dots in validation rule and 1st char should not be . [dot]


  • sal..esforce - invalid
  • sal.esforce - valid
  • .salesforce - invalid
  • salesforce. - valid

Current Rule:

NOT( REGEX( State_Country__c 
, "[a-zA-Z0-9-_]*")), 

CONTAINS(LEFT( State_Country__c , 1), "_"),

CONTAINS(LEFT(State_Country__c , 1), ".")


Your regex might be causing you issues

I've had a go at changing this. It should pass your criteria, if not let me know


Demo of it here with your listed criteria

  • I'd think ^\\.+|(?>\\w\\.{2,}\\w?) would probably be a better regex here. Captures cases with 1 or more dots at the beginning, or 2+ dots in between word characters (including at the end of the string). The ?> makes the group non-capturing, and the double backslashes are to appease Salesforce. – Derek F Jan 18 '19 at 17:08
  • You might also want to go into more detail about how this regex would fit in to OP's validation rule – Derek F Jan 18 '19 at 17:09

One simple format should be

OR(CONTAINS(State_Country__c, '..'), LEFT(State_Country__c, 1) == '.')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.