What are the advantages of using preg_* functions over ereg_* functions in PHP?
The advantages of using preg_* functions over ereg_* functions in PHP are that preg_* functions are faster, more powerful, and support Perl-compatible regular expressions (PCRE), which are widely used and have more features compared to POSIX regular expressions supported by ereg_* functions.
// Using preg_match to match a pattern
$string = "Hello, World!";
if (preg_match("/Hello/", $string)) {
echo "Pattern found in the string.";
} else {
echo "Pattern not found in the string.";
}