3v4l.org

run code in 300+ PHP versions simultaneously
<?php $regex = '#^/(?<owner>[^/]+)/(?<tournament>[^/]+)/(?<league>[^/]+)/(?<team1>[^/\-]+)\-(?<team1_number>\d+)_(?<team2>[^_\-]+)\-(?<team2_number>\d+)(?:\.(?<_format>html|xml|json))?$#s'; // 0.0165 ms avg $optRegex = '#^/(?<owner>[^/]++)/(?<tournament>[^/]++)/(?<league>[^/]++)/(?<team1>[^/\-]++)\-(?<team1_number>\d++)_(?<team2>[^_\-]++)\-(?<team2_number>\d++)(?:\.(?<_format>html|xml|json))?$#s'; // 0.02 ms avg // only needs 82.5% of the time $totaltime = 0; $matches = array(); for ($i = 0; $i < 1000; $i++) { $t = microtime(true); preg_match($regex, '/username/my-tournament', $matches); preg_match($regex, '/username/my-tournament/premier-league', $matches); preg_match($regex, '/username/my-tournament/premier-league/matches', $matches); preg_match($regex, '/username/my-tournament/premier-league/ABC-A_CBA-B', $matches); preg_match($regex, '/username/my-tournament/premier-league/ABC-1_CBA-2.pdf', $matches); preg_match($regex, '/username/my-tournament/premier-league/ABC-1_CBA-2', $matches); $time = ((microtime(true) - $t) * 1000); $totaltime += $time; } echo sprintf('%.4f ms avg', $totaltime / 1000);

preferences:
29.18 ms | 402 KiB | 5 Q