Wednesday, February 19, 2020

How to validate Email address using apex in salesforce

Sample Code

String strEmail = 'test@test.com';
Boolean bValidateEmail = Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}[.]{0,1}[a-zA-Z]{0,2}', strEmail.trim());
System.debug('bValidateEmail ===> '+bValidateEmail);

Output

No comments:

Post a Comment