What are the potential issues with using self-written regular expressions for email validation in PHP?

Using self-written regular expressions for email validation in PHP can lead to inaccuracies and potential security vulnerabilities. It is better to use PHP's built-in filter_var function with the FILTER_VALIDATE_EMAIL flag for accurate and secure email validation.

$email = "example@example.com";

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "Valid email address";
} else {
    echo "Invalid email address";
}