3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rows = [ ['`1234567890-=', '~!@#$%^&*()_+'], ['qwertyuiop[]\\', 'QWERTYUIOP{}|'], ['asdfghjkl;\'', 'ASDFGHJKL:"'], ['zxcvbnm,./', 'ZXCVBNM<>?'] ]; $wholeregex = []; foreach($rows as $k => $row) { $num = $k + 1; echo "Row $num\n"; $array = []; foreach($row as $subrow) { $subarray = array_map('ord', str_split($subrow)); $array = array_merge($subarray, $array); } sort($array); echo "\t" . implode( ' ', $array), "\n"; $ret = [$array[0]]; for($i = 1; $i < count($array); $i++) { $num = $array[$i]; if(($array[$i - 1] + 1) == $num) { if( ($i == (count($array) - 1)) || ($array[$i + 1] != ($num + 1)) ) { $ret[] = array_pop($ret) . '-' . $num; } } else { $ret[] = $num; } } echo "\t" . implode( ' ', $ret), "\n"; $regex = '(['; $subregex = implode( '', array_map(function($el) { $vals = explode('-', $el); if(count($vals) == 1) { return chr($vals[0]); } return chr($vals[0]) . '-' . chr($vals[1]); }, $ret)); $regex .= $subregex; $regex .= '])'; echo "\t" . $regex, "\n"; $wholeregex[] = $regex; } $finalregex = '%' . implode('|', $wholeregex) . '%'; $finalregex = str_replace('(-', '\(-', $finalregex); echo $finalregex, "\n"; echo strlen($finalregex), "\n"; $input = "a"; preg_match($finalregex, $input, $m); echo array_flip($m)[$input];

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0090.00618.54
8.3.50.0110.00621.35
8.3.40.0040.01118.98
8.3.30.0100.00719.04
8.3.20.0000.00720.34
8.3.10.0080.00023.48
8.3.00.0050.00321.89
8.2.180.0080.00818.66
8.2.170.0150.00322.96
8.2.160.0070.00720.56
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0000.00826.16
8.2.120.0080.00021.31
8.2.110.0070.00319.33
8.2.100.0060.00718.17
8.2.90.0050.00319.30
8.2.80.0040.00417.97
8.2.70.0060.00317.88
8.2.60.0000.00818.16
8.2.50.0060.00618.09
8.2.40.0040.00420.58
8.2.30.0000.00719.62
8.2.20.0040.00417.88
8.2.10.0040.00418.13
8.2.00.0040.00418.16
8.1.280.0040.01525.92
8.1.270.0080.00024.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00022.54
8.1.230.0110.00017.89
8.1.220.0000.00817.91
8.1.210.0000.00818.77
8.1.200.0030.00717.73
8.1.190.0050.00317.38
8.1.180.0040.00418.10
8.1.170.0060.00318.89
8.1.160.0040.00420.90
8.1.150.0000.00818.92
8.1.140.0050.00319.54
8.1.130.0040.00417.88
8.1.120.0040.00417.71
8.1.110.0080.00017.68
8.1.100.0080.00017.74
8.1.90.0000.00917.65
8.1.80.0050.00317.68
8.1.70.0000.00717.75
8.1.60.0030.00617.77
8.1.50.0080.00017.78
8.1.40.0000.00917.59
8.1.30.0060.00317.74
8.1.20.0020.00517.89
8.1.10.0000.00917.67
8.1.00.0000.00817.77
8.0.300.0030.00818.77
8.0.290.0050.00317.13
8.0.280.0000.00818.52
8.0.270.0000.00717.34
8.0.260.0030.00617.29
8.0.250.0000.00717.13
8.0.240.0080.00017.17
8.0.230.0030.00317.12
8.0.220.0040.00417.07
8.0.210.0000.00717.13
8.0.200.0040.00417.09
8.0.190.0000.00717.14
8.0.180.0080.00017.17
8.0.170.0030.00717.18
8.0.160.0040.00417.09
8.0.150.0000.00716.95
8.0.140.0000.00716.94
8.0.130.0050.00013.48
8.0.120.0040.00417.07
8.0.110.0080.00017.05
8.0.100.0040.00416.96
8.0.90.0060.00316.96
8.0.80.0060.00917.13
8.0.70.0050.00317.05
8.0.60.0050.00316.96
8.0.50.0080.00017.16
8.0.30.0130.00717.00
8.0.20.0130.00917.45
8.0.10.0080.00017.26
8.0.00.0090.00817.13
7.4.330.0030.00316.79
7.4.320.0070.00016.67
7.4.300.0030.00316.77
7.4.290.0000.00716.84
7.4.280.0040.00416.82
7.4.270.0040.00416.75
7.4.260.0040.00816.75
7.4.250.0040.00416.84
7.4.240.0040.00416.88
7.4.230.0030.00516.78
7.4.220.0030.01616.67
7.4.210.0060.00916.86
7.4.200.0040.00416.78
7.4.160.0080.01216.70
7.4.150.0140.00417.40
7.4.140.0110.01417.86
7.4.130.0070.01216.74
7.4.120.0080.01416.78
7.4.110.0040.01416.73
7.4.100.0120.00616.72
7.4.90.0070.01116.99
7.4.80.0040.01519.39
7.4.70.0110.01116.75
7.4.60.0140.00316.68
7.4.50.0030.01016.83
7.4.40.0070.01016.79
7.4.30.0130.01016.73
7.4.00.0090.00615.45
7.3.330.0020.00613.54
7.3.320.0000.00513.39
7.3.310.0070.00016.48
7.3.300.0000.00716.59
7.3.290.0060.01016.55
7.3.280.0070.01116.51
7.3.270.0130.01117.40
7.3.260.0070.01116.57
7.3.250.0090.01116.67
7.3.240.0090.01216.61
7.3.230.0090.00916.70
7.3.210.0030.01616.82
7.3.200.0160.00319.39
7.3.190.0130.01016.81
7.3.180.0090.00916.64
7.3.170.0070.01016.53
7.3.160.0090.00916.64
7.3.10.0070.00716.68
7.3.00.0050.00316.77
7.2.330.0090.00916.68
7.2.320.0100.01317.00
7.2.310.0030.01416.88
7.2.300.0120.00916.95
7.2.290.0090.00916.89
7.2.130.0080.00416.98
7.2.120.0040.01116.98
7.2.110.0140.00017.11
7.2.100.0070.00717.09
7.2.90.0030.00917.32
7.2.80.0030.00717.16
7.2.70.0000.01117.33
7.2.60.0070.00417.11
7.2.50.0000.01517.12
7.2.40.0070.00317.32
7.2.30.0040.01117.25
7.2.20.0100.00616.90
7.2.10.0070.00717.18
7.2.00.0020.00918.38
7.1.250.0050.00515.70
7.1.100.0060.00318.19
7.1.70.0000.00717.40
7.1.60.0090.01619.40
7.1.50.0100.01417.19
7.1.00.0070.07722.46
7.0.200.0080.00815.07
7.0.60.0200.07722.04
7.0.50.0070.04018.26
7.0.40.0030.04720.57
7.0.30.0230.03720.36
7.0.20.0230.04720.36
7.0.10.0030.05020.45
7.0.00.0070.06020.52
5.6.280.0000.03321.12
5.6.210.0030.05020.56
5.6.200.0100.05718.19
5.6.190.0100.04020.33
5.6.180.0300.07720.50
5.6.170.0300.05020.48
5.6.160.0130.04020.52
5.6.150.0070.06018.16
5.6.140.0130.04018.18
5.6.130.0070.08718.15
5.6.120.0030.08721.14
5.6.110.0070.07020.99
5.6.100.0070.06721.00
5.6.90.0030.07321.14
5.6.80.0200.06020.55
5.5.350.0370.07020.45
5.5.340.0130.07317.96
5.5.330.0070.06320.29
5.5.320.0570.06320.34
5.5.310.0400.06720.23
5.5.300.0100.07718.01
5.5.290.0100.05718.01
5.5.280.0130.08321.00
5.5.270.0100.07320.74
5.5.260.0130.08320.77
5.5.250.0030.09320.60
5.5.240.0330.05720.21

preferences:
57.15 ms | 401 KiB | 5 Q