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; }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
800-555-1111 222-555-1111 888-555-1111 888 555 1111 1 1 2

preferences:
82.35 ms | 406 KiB | 5 Q