What are some potential pitfalls of using the eregi() function in PHP and how can they be avoided?

The eregi() function in PHP is deprecated as of PHP 5.3.0 and removed in PHP 7.0.0 due to performance and security reasons. It is recommended to use the preg_match() function with the 'i' modifier instead for case-insensitive matching.

// Using preg_match() with 'i' modifier for case-insensitive matching
if (preg_match('/pattern/i', $string)) {
    // Match found
} else {
    // No match found
}