What are the potential pitfalls of using regular expressions (regex) in PHP for data validation?

One potential pitfall of using regular expressions for data validation in PHP is that they can be complex and difficult to maintain, especially for more intricate validation rules. To solve this issue, consider using built-in PHP functions or libraries specifically designed for data validation, as they can offer more readability and maintainability.

// Using filter_var function for data validation
$email = "example@example.com";
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "Email is valid";
} else {
    echo "Email is not valid";
}