1

I have a RegEx created and tested in regex platforms, this one:

;.+$

If I check its functionality the result is okay, you could check it too in this link https://regex101.com/r/ocDofm/1/.

The problem is that, when I implement it into a Validation Rule for a Specific field, it does not work. My Validation Rule is :

REGEX( Email__c, ';.+$')

And, if I put the same text that I use on regex101.com web, the Validation Rule does not run. For example, if I open Email__c field, which is a Long Text Area field, and I put this text;

test@test.com;test2@test.com;and so on...

Validation Rule should work and error message should appear, but it happens nothing.

Any idea? Thanks.

EDIT: There is an example of the text that I want to be possible in the Email__c field:

john@gmail.com;
anne@gmail.com;
lewis@gmail.com;

So, the next text, should fire the Validation Rule:

john@gmail.com;a
anne@gmail.com;
lewis@gmail.com;
2
  • 1
    What exactly do you expect the validation rule to allow and disallow? – Phil W Mar 1 at 10:05
  • It must avoid that user put so many emails inline. So, the rule is that user must put emails ending with ';' and with line breaks, he cannot put characters after the ';' character in the same line. – CPS Mar 1 at 10:13
6

That's because SFDC matches the whole field against your REGEX, your whole Email__c is not only ';.+$', plus $ is a special character, so you need something like this

REGEX( Email__c, '.*[;.+$].*')

If you're only interested in ; character then put it like this '.*;.*'

Another point is that if you are only curious about ; character you can use CONTAINS(Email__c, ';')

UPDATE:

Try this one .*;[^\n].*, this should only trigger when you don't have new line after ;

UPDATE2:

REGEX( Email__c, '((.||(\r?\n))*;.((\r?\n)||$)(.||(\r?\n))*)')

15
  • I appreciate your help, and it's useful understand more about regex and validationrules, but still not working... – CPS Mar 1 at 10:26
  • Emails must end with ";" character, and be listed with line breaks. Example: john@gmail.com;(line break) anne@gmail.com;(line break) lewis@gmail.com; – CPS Mar 1 at 10:29
  • so if you have line break it's ok, if you don't have line break it's an error? – ytiq Mar 1 at 10:32
  • I just tested without line breaks and my Regex works, I'll update it for line breaks right now – ytiq Mar 1 at 10:33
  • Sorry, I put the example on my question text, because here in this comments I could not put properly. – CPS Mar 1 at 10:33

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.