In PHP 7.x, ereg functions are no longer supported. Based on my search on internet, ereg functions use a very limited regex flavor called POSIX ERE - meaning pref functions can cover more REGEX syntax as designed.

Below example shows the alternative method in preg functions

ereg functionsrecommended alternative functions

eregi( string $pattern , string $string ) : int

$source = "My email address is Chun Kang<ck@qsok.com>.";
if (ereg("email", $source)) {
  echo "the source has 'email' on the content";
}

preg_match( string $pattern , string $subject ) : int

$source = "My email address is Chun Kang<ck@qsok.com>.";
if (preg("/email/", $source)) {
  echo "the source has 'email' on the content";
}

eregi( string $pattern , string $string ) : int

$source = "My email address is Chun Kang<ck@qsok.com>.";
if (eregi("chun kang", $source)) {
  echo "the source has 'chun kang' on the content";
}
preg_match( string $pattern , string $subject ) : int
$source = "My email address is Chun Kang<ck@qsok.com>.";
if (preg_match("/Chun Kang/i", $source)) {
  echo "the source has 'email' on the content";
}

eregi( string $pattern , string $string , array &$regs ) : int

$source = "My email address is Chun Kang<ck@qsok.com>.";
if (eregi("<(.*)@(.*)>", $source, $output)) {
	print_r($output);
}

Result

Array
(
    [0] => <ck@qsok.com>
    [1] => ck
    [2] => qsok.com
)

preg_match( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] ) : int

$source = "My email address is Chun Kang<ck@qsok.com>.";
if (preg_match("/<(.*)@(.*)>/i", $source, $output)) {
	print_r($output);
}

Result

Array
(
    [0] => <ck@qsok.com>
    [1] => ck
    [2] => qsok.com
)

ereg_replace ( string $pattern , string $replacement , string $string ) : string


$source = "My email address is Chun Kang<ck@qsok.com>.";
$result = ereg_replace("<(.*)>","<kurapa@kurapa.com>", $source);
echo $source . "\n";
echo $result . "\n";

Result

My email address is Chun Kang<ck@qsok.com>.
My email address is Chun Kang<kurapa@kurapa.com>.

preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] ) : mixed

$source = "My email address is Chun Kang<ck@qsok.com>.";
$result = preg_replace("/<(.*)>/","<kurapa@kurapa.com>", $source);
echo $source . "\n";
echo $result . "\n";

Result

My email address is Chun Kang<ck@qsok.com>.
My email address is Chun Kang<kurapa@kurapa.com>.

Reference URLs