What are the advantages of using preg* functions over ereg* functions in PHP form validation?

The advantages of using preg* functions over ereg* functions in PHP form validation are that preg* functions are more powerful, flexible, and efficient for handling regular expressions. They provide better performance and support more advanced features compared to ereg* functions. Additionally, preg* functions are the recommended choice for working with regular expressions in PHP as ereg* functions have been deprecated since PHP 5.3.0.

// Example of using preg_match for form validation
$email = "example@example.com";

if (preg_match("/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/", $email)) {
    echo "Valid email address";
} else {
    echo "Invalid email address";
}