3v4l.org

run code in 300+ PHP versions simultaneously
<?php $username_pattern = '/^(?!\d*$)[a-z0-9]{8,20}$/'; $userNames = [ "1a3b5678", "1a3b5678abcd", "12345678", "1a3b5678abcddddddddddddddddddddddddddddddd", "1a3B5678", "a1" ]; foreach ($userNames as $userName) { if (preg_match($username_pattern, $userName)) { echo "Match - $userName" . PHP_EOL; } else { echo "No match - $userName" . PHP_EOL; } }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.26, 8.1.0 - 8.1.13
Match - 1a3b5678 Match - 1a3b5678abcd No match - 12345678 No match - 1a3b5678abcddddddddddddddddddddddddddddddd No match - 1a3B5678 No match - a1

preferences:
69.95 ms | 409 KiB | 5 Q