How can regular expressions be effectively used to solve the problem of finding an exact number in a string in PHP?

Regular expressions can be effectively used to find an exact number in a string in PHP by using the \d pattern to match any digit, and specifying the exact number of digits to match. This can be achieved by using the preg_match function in PHP with the appropriate regular expression pattern.

$string = "The price is $25.99";
$number = '';
if (preg_match('/\$\d+\.\d{2}/', $string, $matches)) {
    $number = $matches[0];
    echo "Exact number found: " . $number;
} else {
    echo "No exact number found in the string.";
}