Sample Code:
String tempStr = '[email protected]';
if ( Pattern.matches( '[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}', tempStr ) ) {
System.debug( 'Regex Matched' );
} else {
System.debug( 'Regex Pattern not Matched' );
}
Output: