Regular Expression for email validation using Apex in Salesforce

Regular Expression for email validation using Apex in Salesforce

Sample Regular Expression for email validation using Apex is given below

Sample Code:
                

                if(Pattern.matches(‘[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}’, email))
                {
                    //success
                }
                else
                {
                    //error       
                }

Cheers!!!

Leave a Reply