Support Article
Edit Validate rule does not work for specific regular expression
SA-92150
Summary
When using the below expression to validate an email address, the Edit Validate rule does not work.
^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$
Error Messages
Not Applicable
Steps to Reproduce
Create an Edit Validate rule on a property. Verify the validation for the below expression.
^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$
Root Cause
An issue in the custom application code or rules.
The Edit Validate rule logic was configured incorrectly.
Resolution
Perform the following local-change:
Configure the Edit Validate rule as below.
String regex = "^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$";
String email = theValue ;
java.util.regex.Pattern p = java.util.regex.Pattern.compile(regex);
java.util.regex.Matcher m = p.matcher(email); return m.matches();
Published October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.