What potential pitfalls can arise from using eregi() to search for HTML tags in a string?

Using eregi() to search for HTML tags in a string can lead to potential pitfalls because eregi() is a case-insensitive function and may not accurately match HTML tags that are case-sensitive. To solve this issue, it is recommended to use the preg_match() function with a regular expression pattern that explicitly matches HTML tags in a case-sensitive manner.

// Using preg_match() with a case-sensitive regular expression to search for HTML tags in a string
$string = "<div>This is a sample HTML string with <b>tags</b></div>";
$pattern = '/<[^>]*>/';
if (preg_match($pattern, $string, $matches)) {
    echo "HTML tag found: " . $matches[0];
} else {
    echo "No HTML tag found";
}