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); var_dump($m);

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.5.10.0140.00520.15
8.5.00.0120.01020.38
8.4.150.0020.00114.05
8.4.140.0170.00717.91
8.4.130.0110.01018.96
8.4.120.0050.00419.00
8.4.110.0120.00918.90
8.4.100.0120.00918.14
8.4.90.0110.00420.46
8.4.80.0100.01018.73
8.4.70.0090.01118.96
8.4.60.0150.00620.92
8.4.50.0050.00520.36
8.4.40.0120.00918.04
8.4.30.0110.01118.05
8.4.20.0100.01018.02
8.4.10.0050.00518.12
8.3.280.0110.01018.46
8.3.270.0140.00517.02
8.3.260.0120.00816.84
8.3.250.0120.00816.70
8.3.240.0140.00617.00
8.3.230.0120.00816.88
8.3.220.0040.00419.04
8.3.210.0110.00917.05
8.3.200.0030.00616.89
8.3.190.0070.01218.82
8.3.180.0110.00820.91
8.3.170.0160.00317.29
8.3.160.0000.01816.86
8.3.150.0080.00817.05
8.3.140.0060.00317.20
8.3.130.0260.00316.54
8.3.120.0110.00719.06
8.3.110.0090.00020.94
8.3.100.0060.00324.06
8.3.90.0070.00726.77
8.3.80.0050.00517.97
8.3.70.0130.00318.43
8.3.60.0040.01417.00
8.3.50.0140.00722.14
8.3.40.0160.00619.04
8.3.30.0080.00818.96
8.3.20.0080.00020.29
8.3.10.0080.00023.67
8.3.00.0030.00521.90
8.2.290.0130.00717.02
8.2.280.0160.00518.54
8.2.270.0130.00316.74
8.2.260.0090.00016.84
8.2.250.0080.00016.91
8.2.240.0060.00317.15
8.2.230.0090.00022.58
8.2.220.0040.00437.54
8.2.210.0060.00326.77
8.2.200.0090.00016.88
8.2.190.0120.00316.60
8.2.180.0040.01216.88
8.2.170.0180.00422.96
8.2.160.0140.00420.49
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0000.00821.15
8.2.120.0080.00026.35
8.2.110.0000.01019.43
8.2.100.0030.00918.01
8.2.90.0040.00418.13
8.2.80.0090.00319.14
8.2.70.0040.00817.75
8.2.60.0000.00818.29
8.2.50.0060.00318.07
8.2.40.0040.00420.14
8.2.30.0040.00418.22
8.2.20.0000.01017.88
8.2.10.0090.00018.13
8.2.00.0030.00718.26
8.1.330.0100.00916.48
8.1.320.0120.01016.75
8.1.310.0090.00016.54
8.1.300.0130.01020.37
8.1.290.0040.00430.84
8.1.280.0110.00725.92
8.1.270.0150.00322.23
8.1.260.0080.00028.09
8.1.250.0090.00028.09
8.1.240.0080.00419.51
8.1.230.0000.01117.83
8.1.220.0000.00818.04
8.1.210.0040.00418.77
8.1.200.0070.00217.63
8.1.190.0060.00317.73
8.1.180.0040.00418.10
8.1.170.0060.00318.83
8.1.160.0000.00818.94
8.1.150.0030.00518.90
8.1.140.0030.00519.69
8.1.130.0040.00417.67
8.1.120.0030.00617.68
8.1.110.0040.00417.66
8.1.100.0000.00817.67
8.1.90.0000.00717.60
8.1.80.0070.00017.68
8.1.70.0030.00317.72
8.1.60.0060.00317.73
8.1.50.0040.00417.63
8.1.40.0060.00317.64
8.1.30.0030.00617.90
8.1.20.0030.00617.88
8.1.10.0080.00017.77
8.1.00.0000.00817.71
8.0.300.0100.00018.77
8.0.290.0080.00016.88
8.0.280.0000.00818.53
8.0.270.0030.00317.25
8.0.260.0040.00417.37
8.0.250.0070.00017.19
8.0.240.0000.00717.05
8.0.230.0000.00817.06
8.0.220.0000.00717.03
8.0.210.0040.00417.17
8.0.200.0050.00217.02
8.0.190.0040.00417.20
8.0.180.0030.00617.16
8.0.170.0030.00617.02
8.0.160.0040.00417.09
8.0.150.0040.00417.06
8.0.140.0030.00616.94
8.0.130.0070.00013.52
8.0.120.0040.00416.95
8.0.110.0040.00417.12
8.0.100.0000.00816.98
8.0.90.0000.00817.04
8.0.80.0090.00617.05
8.0.70.0040.00417.18
8.0.60.0000.00816.99
8.0.50.0000.00717.08
8.0.30.0050.01617.48
8.0.20.0130.00717.40
8.0.10.0050.00317.18
8.0.00.0120.00717.02
7.4.330.0050.00016.76
7.4.320.0000.00716.86
7.4.300.0000.00816.68
7.4.290.0000.00716.75
7.4.280.0030.00616.74
7.4.270.0000.00716.74
7.4.260.0040.00716.75
7.4.250.0040.00416.73
7.4.240.0020.00516.79
7.4.230.0000.00716.81
7.4.220.0140.00916.90
7.4.210.0100.00716.94
7.4.200.0040.00416.78
7.4.160.0040.01216.47
7.4.150.0090.00917.40
7.4.140.0130.01317.86
7.4.130.0110.00716.83
7.4.120.0100.00916.72
7.4.110.0130.00416.65
7.4.100.0120.00616.86
7.4.90.0120.00616.75
7.4.80.0120.00619.39
7.4.70.0080.00816.77
7.4.60.0070.01116.79
7.4.50.0070.00716.92
7.4.40.0140.01116.82
7.4.30.0100.01616.75
7.4.10.0020.01815.18
7.4.00.0070.01115.21
7.3.330.0000.00713.55
7.3.320.0050.00013.61
7.3.310.0000.00716.44
7.3.300.0070.00016.55
7.3.290.0130.00716.54
7.3.280.0070.00716.57
7.3.270.0060.01217.40
7.3.260.0090.00916.54
7.3.250.0120.00916.62
7.3.240.0070.01116.82
7.3.230.0130.00716.44
7.3.210.0160.00416.77
7.3.200.0100.00719.39
7.3.190.0120.00616.83
7.3.180.0100.01316.46
7.3.170.0030.01216.63
7.3.160.0090.00916.56
7.3.130.0050.00915.23
7.3.120.0080.00915.00
7.3.110.0090.00915.08
7.3.100.0060.00915.12
7.3.90.0070.00714.98
7.3.80.0020.00915.13
7.3.70.0020.01315.06
7.3.60.0070.00814.95
7.3.50.0040.00914.98
7.3.40.0050.00914.98
7.3.30.0070.00714.99
7.3.20.0090.00316.78
7.3.10.0040.00816.97
7.3.00.0070.00716.99
7.2.330.0060.01216.94
7.2.320.0170.00716.77
7.2.310.0080.01116.88
7.2.300.0110.00716.83
7.2.290.0080.01616.92
7.2.260.0090.01115.36
7.2.250.0070.01315.29
7.2.240.0080.01015.50
7.2.230.0070.00815.25
7.2.220.0040.01115.37
7.2.210.0050.00915.25
7.2.200.0050.00915.30
7.2.190.0080.00715.40
7.2.180.0060.00815.28
7.2.170.0050.00815.36
7.2.160.0080.00615.27
7.2.150.0050.01117.12
7.2.140.0080.00617.05
7.2.130.0080.00617.15
7.2.120.0050.00917.10
7.2.110.0080.00717.22
7.2.100.0070.01016.96
7.2.90.0070.00817.14
7.2.80.0070.00516.88
7.2.70.0050.00917.17
7.2.60.0090.00817.08
7.2.50.0040.00917.18
7.2.40.0080.00617.13
7.2.30.0050.01117.18
7.2.20.0050.00917.18
7.2.10.0020.01616.99
7.2.00.0040.01117.94
7.1.330.0040.01115.98
7.1.320.0030.00915.92
7.1.310.0060.00915.86
7.1.300.0080.00715.87
7.1.290.0040.00816.02
7.1.280.0040.01015.92
7.1.270.0060.00815.86
7.1.260.0080.00615.96
7.1.250.0020.01016.09
7.1.240.0050.00615.84
7.1.230.0080.00915.96
7.1.220.0050.01016.03
7.1.210.0030.01116.01
7.1.200.0080.00515.95
7.1.190.0080.00615.86
7.1.180.0030.01216.07
7.1.170.0070.00915.96
7.1.160.0060.01116.11
7.1.150.0020.01015.91
7.1.140.0050.01116.01
7.1.130.0020.01215.75
7.1.120.0050.00815.93
7.1.110.0060.00915.96
7.1.100.0070.00616.74
7.1.90.0000.01316.05
7.1.80.0100.00715.92
7.1.70.0040.00716.40
7.1.60.0110.00717.23
7.1.50.0050.01316.43
7.1.40.0080.00915.94
7.1.30.0060.00815.94
7.1.20.0070.00615.84
7.1.10.0060.00815.78
7.1.00.0020.03617.96
7.0.330.0050.00915.60
7.0.320.0090.00815.65
7.0.310.0070.00415.68
7.0.300.0040.01115.71
7.0.290.0040.00915.58
7.0.280.0020.01115.32
7.0.270.0030.01115.51
7.0.260.0060.00415.67
7.0.250.0100.00515.78
7.0.240.0020.01015.64
7.0.230.0050.00915.58
7.0.220.0030.01115.60
7.0.210.0030.00815.71
7.0.200.0040.01115.32
7.0.190.0070.00515.62
7.0.180.0070.00615.57
7.0.170.0090.00515.74
7.0.160.0050.00515.71
7.0.150.0050.01015.78
7.0.140.0050.00815.64
7.0.130.0050.01015.62
7.0.120.0070.00515.54
7.0.110.0040.00815.67
7.0.100.0050.01115.72
7.0.90.0090.00715.71
7.0.80.0020.01315.59
7.0.70.0050.01115.74
7.0.60.0130.02618.03
7.0.50.0080.02316.85
7.0.40.0080.02316.18
7.0.30.0100.02916.08
7.0.20.0030.02816.32
7.0.10.0120.03016.21
7.0.00.0080.02816.17
5.6.400.0060.00714.78
5.6.390.0060.00614.73
5.6.380.0060.00714.50
5.6.370.0030.01014.64
5.6.360.0050.01114.45
5.6.350.0080.00214.65
5.6.340.0060.00914.44
5.6.330.0080.00814.56
5.6.320.0010.01214.46
5.6.310.0000.01414.23
5.6.300.0030.00914.48
5.6.290.0060.01014.56
5.6.280.0060.01316.70
5.6.270.0030.01014.66
5.6.260.0050.01014.46
5.6.250.0040.01114.77
5.6.240.0060.01114.64
5.6.230.0070.01014.39
5.6.220.0080.00714.45
5.6.210.0080.02816.64
5.6.200.0080.03115.79
5.6.190.0090.03316.64
5.6.180.0110.02416.47
5.6.170.0120.02616.48
5.6.160.0070.03416.55
5.6.150.0080.02215.77
5.6.140.0050.02015.77
5.6.130.0070.01915.86
5.6.120.0080.03316.69
5.6.110.0060.02816.81
5.6.100.0040.03416.76
5.6.90.0040.04216.67
5.6.80.0080.03216.60
5.6.70.0080.00914.30
5.6.60.0070.00514.42
5.6.50.0080.00814.63
5.6.40.0030.01314.47
5.6.30.0050.01014.11
5.6.20.0050.01114.46
5.6.10.0050.00714.44
5.6.00.0020.01514.43
5.5.380.0080.00814.68
5.5.370.0080.00614.36
5.5.360.0070.00614.53
5.5.350.0160.03016.57
5.5.340.0060.02515.79
5.5.330.0070.03316.37
5.5.320.0100.01916.58
5.5.310.0140.02116.39
5.5.300.0060.01715.70
5.5.290.0040.03215.64
5.5.280.0070.03316.81
5.5.270.0070.02616.65
5.5.260.0080.03216.60
5.5.250.0060.03016.54
5.5.240.0170.02116.41
5.5.230.0070.01014.41
5.5.220.0070.00514.38
5.5.210.0080.00614.54
5.5.200.0070.00914.33
5.5.190.0070.00914.39
5.5.180.0030.01314.37
5.5.170.0020.01314.50
5.5.160.0010.01014.55
5.5.150.0090.00614.34
5.5.140.0040.00814.26
5.5.130.0050.01114.45
5.5.120.0050.00914.54
5.5.110.0060.00914.39
5.5.100.0030.01114.51
5.5.90.0050.00614.44
5.5.80.0100.00314.51
5.5.70.0060.00714.64
5.5.60.0090.00314.25
5.5.50.0110.00314.38
5.5.40.0030.01214.34
5.5.30.0080.00614.45
5.5.20.0040.01214.40
5.5.10.0070.00814.47
5.5.00.0100.00414.63

preferences:
39.6 ms | 403 KiB | 5 Q