How can the PHP function eregi be used to extract specific content from a webpage?

The PHP function eregi can be used to extract specific content from a webpage by searching for a specific pattern or regular expression within the webpage content. This function is case-insensitive, making it easier to match patterns without worrying about case sensitivity. By using eregi, you can extract specific content such as email addresses, URLs, or any other patterns you define from the webpage.

<?php
// Get the webpage content
$url = 'https://www.example.com';
$content = file_get_contents($url);

// Define the pattern to search for
$pattern = '/<title>(.*?)<\/title>/i'; // Extract the title tag content

// Use eregi to match the pattern in the webpage content
if (eregi($pattern, $content, $matches)) {
    // Display the extracted content
    echo "Title: " . $matches[1];
} else {
    echo "Pattern not found in the webpage content.";
}
?>