Are there any potential pitfalls when using regular expressions to extract numbers from a string in PHP?

One potential pitfall when using regular expressions to extract numbers from a string in PHP is that the regex pattern may not account for all possible number formats, leading to inaccurate results. To solve this, it's important to carefully design the regex pattern to handle various number formats, such as integers, decimals, negative numbers, and scientific notation.

$string = "The price is $10.50 for 2 items";
preg_match_all('/-?\d*\.?\d+/', $string, $matches);
$numbers = $matches[0];
print_r($numbers);