<?php
<?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($optRegex, '/username/my-tournament', $matches);
preg_match($optRegex, '/username/my-tournament/premier-league', $matches);
preg_match($optRegex, '/username/my-tournament/premier-league/matches', $matches);
preg_match($optRegex, '/username/my-tournament/premier-league/ABC-A_CBA-B', $matches);
preg_match($optRegex, '/username/my-tournament/premier-league/ABC-1_CBA-2.pdf', $matches);
preg_match($optRegex, '/username/my-tournament/premier-league/ABC-1_CBA-2', $matches);
$time = ((microtime(true) - $t) * 1000);
$totaltime += $time;
}
echo sprintf('%.4f ms avg', $totaltime / 1000);
- Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.21
- Parse error: syntax error, unexpected '<' in /in/a7BYl on line 3
Process exited with code 255.
preferences:
187.94 ms | 1387 KiB | 57 Q