Validate email address

PHOTO EMBED

Wed Jun 09 2021 09:34:03 GMT+0000 (Coordinated Universal Time)

Saved by @rfeitor ##salesforce ##validate

/**
  * validateEmail
  * @param email, email address
  * @return boolean, if email valid
  */
private static boolean validateEmail (string email) {
    string emailRegex = '^[a-zA-Z0-9._|\\\\%#~`=?&/$^*!}{+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$';
    pattern outPattern = pattern.compile(emailRegex);
    matcher outMatcher = outPattern.matcher(email);
    return outMatcher.matches();	
}
content_copyCOPY

Validate email address that can be used across all classes and projects