3v4l.org

run code in 300+ PHP versions simultaneously
<?php $meta_pattern = '/(?<=^|%3$s|\s)(?:(?!\S*%3$s\S*)\S+\s+){0,%2$d}(?:(?!\S*%3$s\S*%1$s)\S*)?%1$s\S*?(?:\s+\S+?){0,%2$d}(?=$|%3$s|\s)/'; $reg = sprintf($meta_pattern, preg_quote('search','/'), 3, preg_quote('$@','/')); $tests = array( array('input' => 'a b c d search e f g h', 'expected' => 'b c d search e f g'), array('input' => 'b c d search e f g h', 'expected' => ''), array('input' => 'a b c d search e f g', 'expected' => ''), array('input' => 'c d search e f g h', 'expected' => ''), array('input' => 'a b c d search e f', 'expected' => ''), array('input' => 'a$@b c d search e f g h', 'expected' => ''), array('input' => 'a b c d search e f g$@h', 'expected' => ''), array('input' => 'a b$@c d search e f g h', 'expected' => ''), array('input' => 'a b c d search e f$@g h', 'expected' => ''), array('input' => 'a b c$@d search e f g h', 'expected' => ''), array('input' => 'a b c d search e$@f g h', 'expected' => ''), array('input' => 'a b c d$@search e f g h', 'expected' => ''), array('input' => 'a b c d search$@e f g h', 'expected' => ''), array('input' => 'a b c d$@search$@e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f g h', 'expected' => ''), array('input' => 'b c d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f g', 'expected' => ''), array('input' => 'c d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f', 'expected' => ''), array('input' => 'a$@b c d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f g$@h', 'expected' => ''), array('input' => 'a b$@c d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f$@g h', 'expected' => ''), array('input' => 'a b c$@d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e$@f g h', 'expected' => ''), array('input' => 'a b c d$@xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx$@e f g h', 'expected' => ''), array('input' => 'a b c d$@xsearchx$@e f g h', 'expected' => '') ); foreach($tests as $test) { preg_match($reg,$test['input'],$res); assert($res && !empty($res[0]) && $res[0]==$test['expected']); }

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.0080.00816.63
8.3.50.0280.00322.19
8.3.40.0170.00318.89
8.3.30.0080.00819.14
8.3.20.0080.00020.34
8.3.10.0020.00521.89
8.3.00.0060.00319.63
8.2.180.0100.01016.75
8.2.170.0060.01322.96
8.2.160.0070.01421.98
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0030.00519.79
8.2.110.0070.00321.02
8.2.100.0060.00617.88
8.2.90.0060.00319.17
8.2.80.0080.00017.97
8.2.70.0030.00717.75
8.2.60.0030.00618.16
8.2.50.0050.00318.07
8.2.40.0030.00719.88
8.2.30.0030.00618.32
8.2.20.0040.00417.89
8.2.10.0030.00618.30
8.2.00.0050.00218.00
8.1.280.0040.01125.92
8.1.270.0080.00018.96
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.78
8.1.230.0120.00017.61
8.1.220.0040.00417.91
8.1.210.0030.00618.77
8.1.200.0060.00317.60
8.1.190.0080.00017.47
8.1.180.0040.00418.10
8.1.170.0090.00020.37
8.1.160.0070.00022.14
8.1.150.0000.00718.88
8.1.140.0000.00817.70
8.1.130.0040.00417.95
8.1.120.0020.00517.68
8.1.110.0000.00717.72
8.1.100.0040.00417.62
8.1.90.0040.00417.58
8.1.80.0040.00417.51
8.1.70.0000.00717.71
8.1.60.0040.00417.84
8.1.50.0040.00417.74
8.1.40.0100.00017.73
8.1.30.0040.00417.80
8.1.20.0090.00017.68
8.1.10.0040.00417.73
8.1.00.0000.00817.70
8.0.300.0040.00418.77
8.0.290.0000.00716.88
8.0.280.0000.00718.45
8.0.270.0000.00717.33
8.0.260.0000.00717.33
8.0.250.0000.00717.19
8.0.240.0040.00417.25
8.0.230.0040.00717.13
8.0.220.0030.00317.04
8.0.210.0050.00317.05
8.0.200.0070.00017.19
8.0.190.0040.00417.25
8.0.180.0040.00417.07
8.0.170.0080.00017.20
8.0.160.0050.00317.09
8.0.150.0080.00017.10
8.0.140.0040.00417.15
8.0.130.0050.00313.61
8.0.120.0040.00417.15
8.0.110.0040.00417.09
8.0.100.0030.00517.02
8.0.90.0000.00716.96
8.0.80.0100.00717.20
8.0.70.0000.00717.13
8.0.60.0080.00017.02
8.0.50.0000.00717.21
8.0.30.0100.01117.30
8.0.20.0130.00717.44
8.0.10.0040.00417.25
8.0.00.0090.00817.24
7.4.330.0030.00315.12
7.4.320.0000.00816.88
7.4.300.0000.00816.91
7.4.290.0080.00016.71
7.4.280.0030.00516.80
7.4.270.0000.00716.74
7.4.260.0050.00216.83
7.4.250.0040.00416.86
7.4.240.0040.00416.75
7.4.230.0000.00716.80
7.4.220.0170.01016.71
7.4.210.0120.00616.86
7.4.200.0040.00416.77
7.4.160.0100.00716.84
7.4.150.0120.00817.40
7.4.140.0090.01217.86
7.4.130.0070.01216.67
7.4.120.0150.00316.79
7.4.110.0090.00916.73
7.4.100.0090.00916.86
7.4.90.0090.00916.77
7.4.80.0130.00719.39
7.4.70.0140.00316.75
7.4.60.0100.00716.68
7.4.50.0030.00616.72
7.4.40.0140.01016.80
7.4.30.0030.01816.72
7.4.00.0060.00615.25
7.3.330.0000.00613.31
7.3.320.0070.00713.45
7.3.310.0060.00316.42
7.3.300.0030.00316.57
7.3.290.0030.00316.46
7.3.280.0060.01216.65
7.3.270.0130.00617.40
7.3.260.0120.00616.68
7.3.250.0080.01016.60
7.3.240.0140.01116.75
7.3.230.0040.01316.75
7.3.210.0130.00716.61
7.3.200.0060.01219.39
7.3.190.0030.01316.80
7.3.180.0100.00716.52
7.3.170.0110.00816.70
7.3.160.0100.00716.75
7.2.330.0090.00916.84
7.2.320.0110.00616.87
7.2.310.0100.01416.83
7.2.300.0030.01416.77
7.2.290.0060.01316.83
7.2.60.0030.01317.02
7.2.00.0000.01119.76
7.1.200.0030.00315.95
7.1.100.0000.01418.45
7.1.70.0000.00817.51
7.1.60.0070.01419.50
7.1.50.0120.01217.17
7.1.00.0030.07722.30
7.0.200.0200.00314.89
7.0.140.0100.06321.95
7.0.60.0070.06020.09
7.0.50.0130.06717.82
7.0.40.0100.06020.07
7.0.30.0330.03720.23
7.0.20.0100.07720.12
7.0.10.0300.07720.03
7.0.00.0100.04020.02
5.6.280.0100.06721.12
5.6.210.0030.08720.49
5.6.200.0070.04018.09
5.6.190.0130.07720.67
5.6.180.0200.06020.62
5.6.170.0270.05020.53
5.6.160.0100.06320.52
5.6.150.0000.04318.21
5.6.140.0100.07718.17
5.6.130.0130.08018.18
5.6.120.0070.08721.19
5.6.110.0070.06020.99
5.6.100.0200.07321.02
5.6.90.0100.08321.14
5.6.80.0100.06720.39
5.6.70.0200.06720.38
5.5.350.0130.08020.46
5.5.340.0070.05017.99
5.5.330.0070.08720.25
5.5.320.0170.08320.57
5.5.310.0230.03720.29
5.5.300.0070.07717.91
5.5.290.0070.04018.00
5.5.280.0130.08020.91
5.5.270.0070.09020.89
5.5.260.0170.06720.63
5.5.250.0130.08020.51
5.5.240.0130.08020.27
5.4.450.0670.06019.35
5.4.440.0830.06019.43
5.4.430.0800.06319.27
5.4.420.0430.06019.47
5.4.410.0970.04718.97
5.4.400.0200.05718.52
5.4.390.0270.06318.69
5.4.380.0200.06318.54
5.4.370.0230.06318.64
5.4.360.0170.05718.55
5.4.350.0200.05718.60
5.4.340.0230.05318.80
5.4.320.0430.03318.59
5.4.310.0230.05018.72
5.4.300.0170.06318.51
5.4.290.0230.05018.72
5.4.280.0430.03318.54
5.4.270.0130.06718.59
5.4.260.0230.05318.51
5.4.250.0200.05718.70
5.4.240.0330.04718.70
5.4.230.0330.05318.66
5.4.220.0330.04718.72
5.4.210.0200.05718.69
5.4.200.0270.05716.44
5.4.190.0200.05318.50
5.4.180.0270.04718.72
5.4.170.0270.05018.70
5.4.160.0200.06018.75
5.4.150.0300.04318.52
5.4.140.0130.06016.07
5.4.130.0270.04716.25
5.4.120.0170.06716.18
5.4.110.0330.04316.31
5.4.100.0230.05016.33
5.4.90.0200.05716.09
5.4.80.0170.05716.30
5.4.70.0200.04716.21
5.4.60.0130.05716.14
5.4.50.0130.04716.26
5.4.40.0130.06016.16
5.4.30.0130.05716.21
5.4.20.0130.06716.25
5.4.10.0100.05716.29
5.4.00.0170.05315.67
5.3.290.0230.05314.64
5.3.280.0270.04714.72
5.3.270.0230.05014.63
5.3.260.0200.05714.63
5.3.250.0170.06014.67
5.3.240.0100.06014.67
5.3.230.0170.06014.59
5.3.220.0300.06014.75
5.3.210.0170.06014.68
5.3.200.0270.06314.67
5.3.190.0230.05014.57
5.3.180.0170.06014.51
5.3.170.0300.05314.59
5.3.160.0300.05314.59
5.3.150.0230.05314.64
5.3.140.0200.05314.57
5.3.130.0200.05714.65
5.3.120.0170.05714.64
5.3.110.0170.06014.54
5.3.100.0230.06013.98
5.3.90.0230.05714.03
5.3.80.0170.05713.96
5.3.70.0200.05314.04
5.3.60.0100.06014.13
5.3.50.0270.06013.92
5.3.40.0230.06013.89
5.3.30.0230.06314.04
5.3.20.0230.06013.80
5.3.10.0230.04713.64
5.3.00.0170.05713.67
5.2.170.0200.04011.14
5.2.160.0070.05011.15
5.2.150.0170.04711.39
5.2.140.0170.05011.21
5.2.130.0200.04011.10
5.2.120.0130.04711.10
5.2.110.0100.04711.15
5.2.100.0170.04311.35
5.2.90.0100.04711.08
5.2.80.0100.04711.11
5.2.70.0230.04011.09
5.2.60.0170.04311.05
5.2.50.0130.04310.98
5.2.40.0100.04311.03
5.2.30.0170.04710.92
5.2.20.0170.04011.02
5.2.10.0070.04311.00
5.2.00.0200.03710.82
5.1.60.0200.03010.01
5.1.50.0100.03710.05
5.1.40.0200.03010.14
5.1.30.0200.03310.40
5.1.20.0200.05010.43
5.1.10.0070.05010.09
5.1.00.0130.04010.25
5.0.50.0070.0378.61
5.0.40.0030.0338.63
5.0.30.0130.0608.38
5.0.20.0130.0378.34
5.0.10.0130.0378.41
5.0.00.0170.0508.33
4.4.90.0070.0275.92
4.4.80.0030.0375.87
4.4.70.0170.0235.93
4.4.60.0100.0305.97
4.4.50.0030.0375.96
4.4.40.0130.0405.95
4.4.30.0130.0175.93
4.4.20.0070.0236.03
4.4.10.0100.0205.94
4.4.00.0070.0406.00
4.3.110.0100.0235.89
4.3.100.0070.0205.87
4.3.90.0230.0305.87
4.3.80.0030.0475.82
4.3.70.0070.0205.94
4.3.60.0100.0205.91
4.3.50.0170.0205.84
4.3.40.0070.0375.88
4.3.30.0030.0274.63
4.3.20.0070.0274.59
4.3.10.0100.0274.59
4.3.00.0100.0207.11

preferences:
46.96 ms | 401 KiB | 5 Q