3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ "1 800-555-1111", "1 222-555-1111", "888-555-1111", "1 888 555 1111", "1 ", "1 2" ]; $pattern = '/^1\h+(?=\d(?:[^\d\n\r]?\d){9}$)/'; foreach ($strings as $s) { echo preg_replace($pattern, '', $s) . PHP_EOL; }

preferences:
24.82 ms | 404 KiB | 5 Q