What are the potential pitfalls of using ereg function for input validation in PHP?

Using the ereg function for input validation in PHP can lead to security vulnerabilities as it is deprecated and has been removed in newer versions of PHP. It is recommended to use the preg_match function with proper regular expressions for input validation to prevent potential security risks.

// Using preg_match for input validation instead of ereg
$input = "example123";

if(preg_match('/^[a-zA-Z0-9]*$/', $input)) {
    echo "Input is valid.";
} else {
    echo "Input is invalid.";
}