3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sanitize_sentence($string) { $pats = array( '/([.!?]\s{2}),/', # Abc. ,Def '/\.+(,)/', # ......, '/(!|\?)\1+/', # abc!!!!!!!!, abc????????? '/\s+(,)/', # abc , def '/([a-zA-Z])\1\1/'); # greeeeeeen $fixed = preg_replace($pats,'$1',$string); $fixed = preg_replace('/,(?!\s)/',', ',$fixed); $fixed = preg_replace( '/([!?,.])(\S)/', '$1 $2', $fixed); $fixed = preg_replace( '/([^a-zA-Z0-9!?.])$/', '.', $fixed); return $fixed; } echo sanitize_sentence('hello!!!!!!there should be a space after the exclamation mark.right???????yes.right,');

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.0070.00716.73
8.3.50.0120.00516.59
8.3.40.0080.01218.96
8.3.30.0080.00818.83
8.3.20.0050.00318.88
8.3.10.0120.00420.75
8.3.00.0050.00519.50
8.2.180.0190.00316.63
8.2.170.0070.00722.96
8.2.160.0140.00021.23
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0030.00717.63
8.2.110.0090.00020.53
8.2.100.0080.00417.91
8.2.90.0050.00319.21
8.2.80.0060.00317.97
8.2.70.0030.00517.63
8.2.60.0040.00417.80
8.2.50.0000.00818.10
8.2.40.0060.00318.22
8.2.30.0040.00418.21
8.2.20.0030.00617.82
8.2.10.0040.00417.73
8.2.00.0100.00017.84
8.1.280.0110.00725.92
8.1.270.0040.00424.66
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00322.21
8.1.230.0080.00317.70
8.1.220.0050.00317.88
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0080.00017.36
8.1.180.0100.00018.10
8.1.170.0050.00318.69
8.1.160.0000.00718.88
8.1.150.0030.00518.80
8.1.140.0030.00717.46
8.1.130.0030.00317.81
8.1.120.0050.00317.63
8.1.110.0000.00817.54
8.1.100.0000.00717.45
8.1.90.0040.00417.57
8.1.80.0040.00417.52
8.1.70.0040.00417.56
8.1.60.0030.00617.75
8.1.50.0030.00517.61
8.1.40.0040.00417.61
8.1.30.0040.00417.64
8.1.20.0060.00317.81
8.1.10.0040.00417.68
8.1.00.0000.00817.47
8.0.300.0070.00018.77
8.0.290.0000.00716.75
8.0.280.0070.00018.50
8.0.270.0000.00817.34
8.0.260.0000.00716.85
8.0.250.0050.00217.18
8.0.240.0000.00717.16
8.0.230.0050.00217.05
8.0.220.0050.00317.00
8.0.210.0000.00716.98
8.0.200.0000.00917.09
8.0.190.0040.00417.02
8.0.180.0040.00416.92
8.0.170.0030.00616.96
8.0.160.0040.00417.04
8.0.150.0040.00716.91
8.0.140.0040.00416.91
8.0.130.0000.00613.35
8.0.120.0000.00716.84
8.0.110.0040.00416.77
8.0.100.0000.00816.84
8.0.90.0030.00516.86
8.0.80.0080.00816.94
8.0.70.0050.00217.06
8.0.60.0000.00816.81
8.0.50.0040.00416.88
8.0.30.0120.00617.21
8.0.20.0140.00517.14
8.0.10.0080.00016.90
8.0.00.0090.01116.84
7.4.330.0000.00513.20
7.4.320.0000.00816.67
7.4.300.0060.00016.81
7.4.290.0030.00316.65
7.4.280.0000.00816.58
7.4.270.0000.00816.84
7.4.260.0060.00013.53
7.4.250.0000.00916.87
7.4.240.0080.00016.68
7.4.230.0030.00316.61
7.4.220.0090.01516.73
7.4.210.0100.00516.85
7.4.200.0000.00816.87
7.4.190.0040.00416.77
7.4.160.0160.00616.88
7.4.150.0090.01016.74
7.4.140.0100.01016.57
7.4.130.0100.00916.70
7.4.120.0100.00716.68
7.4.110.0140.00316.58
7.4.100.0070.01016.56
7.4.90.0130.00616.56
7.4.80.0110.01119.39
7.4.70.0110.00516.59
7.4.60.0090.00916.74
7.4.50.0040.00416.57
7.4.40.0030.01016.44
7.4.30.0120.00616.74
7.4.00.0040.01114.97
7.3.330.0070.00013.35
7.3.320.0000.00513.25
7.3.310.0030.00316.29
7.3.300.0000.00716.27
7.3.290.0080.00816.41
7.3.280.0060.00816.41
7.3.270.0070.01016.47
7.3.260.0140.00716.50
7.3.250.0140.00416.54
7.3.240.0090.00916.76
7.3.230.0060.01216.41
7.3.210.0100.00716.84
7.3.200.0060.01016.80
7.3.190.0060.01216.53
7.3.180.0040.01216.74
7.3.170.0140.00316.68
7.3.160.0070.01016.77
7.3.120.0070.00714.75
7.3.10.0030.01016.57
7.3.00.0130.00416.77
7.2.330.0120.00616.77
7.2.320.0140.00316.87
7.2.310.0090.01816.82
7.2.300.0090.01316.96
7.2.290.0130.01016.81
7.2.130.0100.01016.73
7.2.120.0100.01316.61
7.2.110.0250.00016.46
7.2.100.0040.01416.69
7.2.90.0160.00416.87
7.2.80.0160.00016.84
7.2.70.0160.00916.90
7.2.60.0070.00616.76
7.2.50.0150.00817.13
7.2.40.0130.00316.59
7.2.30.0190.00316.75
7.2.20.0120.00417.02
7.2.10.0160.00316.79
7.2.00.0090.00618.20
7.1.250.0100.00715.81
7.1.200.0060.00316.03
7.1.100.0030.01317.86
7.1.70.0000.01017.35
7.1.60.0170.00319.40
7.1.50.0100.00317.25
7.1.00.0100.07022.38
7.0.200.0150.00415.16
7.0.140.0030.07722.15
7.0.120.0100.06022.20
7.0.60.0000.08320.03
7.0.50.0030.05717.89
7.0.40.0030.04720.14
7.0.30.0370.07020.23
7.0.20.0230.05320.10
7.0.10.0270.08320.21
7.0.00.0000.04720.21
5.6.280.0030.07320.89
5.6.210.0100.07720.71
5.6.200.0000.06018.14
5.6.190.0070.07020.54
5.6.180.0230.04720.58
5.6.170.0200.05320.45
5.6.160.0070.04020.56
5.6.150.0030.05018.14
5.6.140.0070.04318.21
5.6.130.0030.06718.21
5.6.120.0030.05321.12
5.6.110.0130.07721.10
5.6.100.0070.06021.01
5.6.90.0030.04021.00
5.6.80.0200.03020.43
5.6.70.2730.03320.49
5.5.350.0330.07720.39
5.5.340.0070.08017.95
5.5.330.0030.04320.57
5.5.320.0100.05320.26
5.5.310.0270.05020.30
5.5.300.0130.03318.05
5.5.290.0130.07317.92
5.5.280.0000.04720.74
5.5.270.0170.07320.73
5.5.260.0100.07020.87
5.5.250.0030.08720.62
5.5.240.0130.07020.20
5.4.450.0070.05719.39
5.4.440.0070.08019.48
5.4.430.0070.03719.32
5.4.420.0070.05719.17
5.4.410.0030.06719.44
5.4.400.0000.05719.29
5.4.390.0130.09019.14
5.4.380.0100.07318.87
5.4.370.0100.07019.24
5.4.360.0030.08018.98
5.4.350.0070.04719.14
5.4.340.0030.06019.15
5.4.320.0170.06718.85
5.4.310.0130.06719.15
5.4.300.0070.06019.00
5.4.290.0100.05718.87
5.4.280.0070.06018.87
5.4.270.0100.04319.09
5.4.260.0030.08019.23
5.4.250.0070.07319.07
5.4.240.0100.06719.14
5.4.230.0070.04318.92
5.4.220.0100.06719.11
5.4.210.0100.03719.24
5.4.200.0200.05718.86
5.4.190.0070.07719.23
5.4.180.0000.07318.86
5.4.170.0030.04319.19
5.4.160.0100.03019.03
5.4.150.0070.03319.10
5.4.140.0170.03716.46
5.4.130.0030.04016.59
5.4.120.0030.03316.42
5.4.110.0070.03716.50
5.4.100.0070.03316.48
5.4.90.0100.03316.48
5.4.80.0000.04716.71
5.4.70.0100.03316.50
5.4.60.0170.05716.51
5.4.50.0070.03716.31
5.4.40.0030.03716.27
5.4.30.0000.04016.26
5.4.20.0000.04716.44
5.4.10.0000.03716.50
5.4.00.0000.03715.77
5.3.290.0070.04314.74
5.3.280.0130.06714.59
5.3.270.0070.07714.62
5.3.260.0030.04714.65
5.3.250.0030.03714.49
5.3.240.0000.03714.66
5.3.230.0070.03314.62
5.3.220.0070.03714.57
5.3.210.0000.04014.64
5.3.200.0030.03314.73
5.3.190.0130.02714.56
5.3.180.0070.04314.63
5.3.170.0070.04014.48
5.3.160.0130.03314.59
5.3.150.0000.04014.71
5.3.140.0070.05014.56
5.3.130.0000.04714.55
5.3.120.0030.03714.54
5.3.110.0030.04014.46
5.3.100.0070.03314.05
5.3.90.0000.04014.17
5.3.80.0030.03713.90
5.3.70.0070.03314.00
5.3.60.0030.04013.89
5.3.50.0070.05313.95
5.3.40.0070.03013.98
5.3.30.0030.03713.80
5.3.20.0030.03713.61
5.3.10.0000.03713.82
5.3.00.0070.03013.70
5.2.170.0000.03011.14
5.2.160.0030.03011.19
5.2.150.0000.03011.30
5.2.140.0030.03011.17
5.2.130.0000.03011.10
5.2.120.0070.02311.10
5.2.110.0000.03011.04
5.2.100.0030.02711.10
5.2.90.0000.03011.02
5.2.80.0030.02711.25
5.2.70.0030.03311.08
5.2.60.0000.03311.00
5.2.50.0070.02711.02
5.2.40.0030.02711.00
5.2.30.0000.03310.92
5.2.20.0030.02711.12
5.2.10.0030.02710.86
5.2.00.0000.03010.86
5.1.60.0000.02310.14
5.1.50.0000.02710.07
5.1.40.0030.0279.95
5.1.30.0030.02710.39
5.1.20.0000.06310.34
5.1.10.0030.0439.98
5.1.00.0100.05310.00
5.0.50.0100.0438.65
5.0.40.0000.0438.65
5.0.30.0000.0738.65
5.0.20.0030.0238.65
5.0.10.0000.0238.65
5.0.00.0030.0338.65
4.4.90.0000.0178.65
4.4.80.0000.0178.65
4.4.70.0030.0138.65
4.4.60.0000.0178.65
4.4.50.0000.0178.65
4.4.40.0000.0238.65
4.4.30.0000.0138.65
4.4.20.0000.0278.65
4.4.10.0070.0308.65
4.4.00.0000.0538.65
4.3.110.0000.0438.65
4.3.100.0030.0308.65
4.3.90.0100.0238.65
4.3.80.0070.0278.65
4.3.70.0100.0078.65
4.3.60.0070.0278.65
4.3.50.0030.0178.65
4.3.40.0030.0308.65
4.3.30.0000.0208.65
4.3.20.0000.0308.65
4.3.10.0070.0238.65
4.3.00.0030.0308.65

preferences:
57.89 ms | 400 KiB | 5 Q