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

Using eregi_replace in PHP for replacing links can lead to security vulnerabilities as it is case-insensitive and can be exploited by malicious users. To solve this issue, it is recommended to use the preg_replace function with the 'i' modifier for case-insensitive matching.

// Using preg_replace with 'i' modifier for case-insensitive matching
$new_string = preg_replace('/http(s)?:\/\/\S+/', 'replacement_link', $old_string);