What are the potential pitfalls of using regular expressions to validate email addresses in PHP?

Using regular expressions to validate email addresses in PHP can be tricky as they can be complex to write and may not cover all edge cases. It's better to use PHP's built-in filter_var function with the FILTER_VALIDATE_EMAIL filter, which provides a more reliable way to validate email addresses.

$email = "example@example.com";

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