3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '~[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?|\d+|(?>\p{L}\p{M}*+)+~u'; $text = "The example number 2 is a bad example it will not \ncount numbers and punctuations !! X is 2.5674."; if (preg_match_all($re, $text, $matches)) { echo count($matches[0]) . PHP_EOL; print_r($matches[0]); }

preferences:
27.33 ms | 405 KiB | 5 Q