What are some potential pitfalls when using regular expressions to split numbers in PHP?

One potential pitfall when using regular expressions to split numbers in PHP is not accounting for decimal numbers or negative numbers. To avoid this issue, you can modify the regular expression pattern to include optional decimal points and negative signs. Additionally, you should consider handling edge cases such as leading or trailing non-numeric characters.

// Example code snippet to split numbers in PHP while accounting for decimal and negative numbers
$pattern = '/-?\d*\.?\d+/';
$string = "The price is $10.50 and the discount is -5.25";
preg_match_all($pattern, $string, $matches);
$numbers = $matches[0];
print_r($numbers);