What are the potential pitfalls of using eregi_replace for replacing URLs in PHP code?

Using eregi_replace for replacing URLs in PHP code is not recommended because it is a deprecated function and may not work as expected in newer versions of PHP. It is better to use preg_replace with a proper regular expression to replace URLs in PHP code.

// Using preg_replace to replace URLs in PHP code
$string = "Visit my website at http://www.example.com";
$pattern = "/(https?:\/\/)?(www\.)?[a-zA-Z0-9]+\.[a-zA-Z]{2,6}/";
$replacement = "URL_REPLACED";
$new_string = preg_replace($pattern, $replacement, $string);
echo $new_string;