Regular Expression for email validation using Apex in Salesforce.

Sample Regular Expression for email validation using Apex is given below


if(Pattern.matches('([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3}\\.[a-z]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})', email)){
//success
}
else{
//error        
}

Cheers!!! Enjoy

0 comments:

Post a Comment