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.0080.00818.68
8.3.50.0090.00921.14
8.3.40.0140.00718.97
8.3.30.0120.00318.96
8.3.20.0040.00418.95
8.3.10.0000.00821.11
8.3.00.0070.00023.68
8.2.180.0120.00916.75
8.2.170.0140.00722.96
8.2.160.0110.00720.57
8.2.150.0090.00924.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0090.00619.89
8.2.110.0140.00722.04
8.2.100.0090.00317.84
8.2.90.0050.00518.16
8.2.80.0040.00417.97
8.2.70.0060.00317.63
8.2.60.0080.00017.92
8.2.50.0000.00818.07
8.2.40.0080.00018.28
8.2.30.0000.00719.48
8.2.20.0080.00017.87
8.2.10.0070.00017.89
8.2.00.0000.00917.83
8.1.280.0180.00025.92
8.1.270.0080.00023.99
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0030.00620.81
8.1.230.0130.00020.83
8.1.220.0030.00517.88
8.1.210.0040.00418.77
8.1.200.0030.00717.35
8.1.190.0040.00417.39
8.1.180.0000.00818.10
8.1.170.0060.00318.73
8.1.160.0000.00718.71
8.1.150.0000.00718.78
8.1.140.0040.00417.60
8.1.130.0030.00317.86
8.1.120.0000.00817.63
8.1.110.0040.00417.55
8.1.100.0040.00417.52
8.1.90.0040.00417.58
8.1.80.0000.00717.51
8.1.70.0070.00017.54
8.1.60.0030.00617.78
8.1.50.0040.00417.66
8.1.40.0040.00717.60
8.1.30.0000.00817.72
8.1.20.0030.00517.84
8.1.10.0000.00717.55
8.1.00.0000.00817.63
8.0.300.0000.00719.94
8.0.290.0000.00917.28
8.0.280.0070.00018.36
8.0.270.0040.00417.28
8.0.260.0030.00316.99
8.0.250.0000.00717.04
8.0.240.0030.00617.17
8.0.230.0050.00217.00
8.0.220.0030.00317.00
8.0.210.0030.00316.95
8.0.200.0000.00716.90
8.0.190.0040.00417.05
8.0.180.0040.00416.90
8.0.170.0000.01117.05
8.0.160.0020.00517.00
8.0.150.0060.00316.90
8.0.140.0040.00416.85
8.0.130.0030.00313.40
8.0.120.0000.00817.04
8.0.110.0050.00316.79
8.0.100.0000.00816.88
8.0.90.0000.00716.88
8.0.80.0070.01016.96
8.0.70.0030.00516.93
8.0.60.0050.00316.98
8.0.50.0020.00516.77
8.0.30.0080.01417.46
8.0.20.0160.00417.47
8.0.10.0080.00017.13
8.0.00.0090.00817.03
7.4.330.0020.00314.98
7.4.320.0060.00316.66
7.4.300.0030.00316.83
7.4.290.0040.00416.79
7.4.280.0070.00016.71
7.4.270.0030.00516.74
7.4.260.0030.00313.51
7.4.250.0020.00516.59
7.4.240.0050.00216.65
7.4.230.0030.00316.75
7.4.220.0070.01516.88
7.4.210.0070.00916.86
7.4.200.0040.00416.86
7.4.190.0040.00416.69
7.4.160.0100.00716.85
7.4.150.0160.00317.40
7.4.140.0120.00817.86
7.4.130.0130.00516.79
7.4.120.0050.01216.82
7.4.110.0000.02216.72
7.4.100.0110.01016.59
7.4.90.0120.00616.85
7.4.80.0060.01219.39
7.4.70.0070.01016.59
7.4.60.0100.00616.67
7.4.50.0060.00316.68
7.4.40.0030.01022.52
7.4.30.0000.01516.75
7.4.00.0000.00815.20
7.3.330.0030.00313.17
7.3.320.0000.00613.23
7.3.310.0030.00316.50
7.3.300.0040.00416.39
7.3.290.0110.00716.36
7.3.280.0050.01216.39
7.3.270.0120.00617.40
7.3.260.0080.01118.24
7.3.250.0080.01216.62
7.3.240.0140.00616.43
7.3.230.0030.01316.52
7.3.210.0160.00016.68
7.3.200.0090.00919.39
7.3.190.0070.01016.25
7.3.180.0040.01216.44
7.3.170.0080.00816.77
7.3.160.0120.00316.71
7.3.120.0030.01114.79
7.2.330.0060.01216.82
7.2.320.0080.01716.55
7.2.310.0120.00916.89
7.2.300.0040.01816.80
7.2.290.0120.00616.87
7.2.60.0070.00717.11
7.1.200.0040.00415.64
7.1.70.0030.00617.23
7.1.60.0100.01419.40
7.1.50.0130.02134.66
7.1.00.0000.04322.39
7.0.200.0030.00916.92
7.0.140.0100.06722.19
7.0.70.0000.04321.69
7.0.60.0000.04021.84
7.0.50.0030.03322.14
7.0.40.0000.03320.07
7.0.30.0030.06020.18
7.0.20.0030.04320.09
7.0.10.0000.06720.02
7.0.00.0100.04320.11
5.6.280.0030.07020.90
5.6.220.0000.04320.53
5.6.210.0070.03720.72
5.6.200.0000.04321.10
5.6.190.0000.03721.12
5.6.180.0030.06020.95
5.6.170.0070.07320.99
5.6.160.0030.05320.93
5.6.150.0100.03021.07
5.6.140.0030.04321.10
5.6.130.0030.04321.04
5.6.120.0000.03721.00
5.6.110.0030.03321.03
5.6.100.0000.04321.00
5.6.90.0000.03321.05
5.6.80.0070.02720.48
5.6.70.0030.03020.30
5.6.60.0000.03320.48
5.6.50.0000.03320.42
5.6.40.0000.03320.28
5.6.30.0000.03320.41
5.6.20.0070.03320.51
5.6.10.0030.03020.45
5.6.00.0000.03320.39
5.5.360.0030.04020.44
5.5.350.0070.03720.42
5.5.340.0000.04320.82
5.5.330.0030.06020.64
5.5.320.0000.04720.93
5.5.310.0030.04720.91
5.5.300.0070.03320.77
5.5.290.0000.03720.86
5.5.280.0000.03720.86
5.5.270.0030.03320.89
5.5.260.0070.03020.89
5.5.250.0000.03320.63
5.5.240.0100.02320.20
5.5.230.0030.03020.23
5.5.220.0000.03320.20
5.5.210.0000.03320.20
5.5.200.0000.03320.22
5.5.190.0070.03319.98
5.5.180.0030.03720.14
5.5.160.0000.03320.25
5.5.150.0000.08720.07
5.5.140.0030.07020.11
5.5.130.0070.06720.13
5.5.120.0100.07020.18
5.5.110.0070.08020.20
5.5.100.0070.07320.15
5.5.90.0000.07720.10
5.5.80.0000.07320.15
5.5.70.0000.08320.04
5.5.60.0100.07020.05
5.5.50.0100.07020.04
5.5.40.0100.07719.99
5.5.30.0100.05720.04
5.5.20.0000.04720.14
5.5.10.0100.07020.00
5.5.00.0130.07319.94
5.4.450.0030.03719.42
5.4.440.0070.04019.49
5.4.430.0000.04019.55
5.4.420.0000.03719.43
5.4.410.0000.03719.31
5.4.400.0000.03019.04
5.4.390.0000.03319.04
5.4.380.0000.03019.02
5.4.370.0000.03319.15
5.4.360.0070.02719.21
5.4.350.0000.03318.89
5.4.340.0070.03318.95
5.4.320.0000.03319.10
5.4.310.0000.06719.11
5.4.300.0130.06318.94
5.4.290.0000.07718.84
5.4.280.0130.07019.02
5.4.270.0000.05719.02
5.4.260.0000.08019.02
5.4.250.0000.07719.14
5.4.240.0070.07319.02
5.4.230.0030.08019.16
5.4.220.0000.08318.88
5.4.210.0030.06018.86
5.4.200.0000.07719.07
5.4.190.0100.05719.07
5.4.180.0030.05018.88
5.4.170.0030.06719.14
5.4.160.0100.06319.06
5.4.150.0000.08019.07
5.4.140.0030.07016.34
5.4.130.0000.07316.39
5.4.120.0100.06016.43
5.4.110.0070.07316.40
5.4.100.0000.05316.39
5.4.90.0000.07716.49
5.4.80.0000.07316.35
5.4.70.0000.07316.41
5.4.60.0000.08016.40
5.4.50.0070.07316.43
5.4.40.0030.07016.41
5.4.30.0070.07016.39
5.4.20.0030.07316.37
5.4.10.0030.06716.42
5.4.00.0070.06315.71
5.3.290.0030.03714.86
5.3.280.0070.05314.86
5.3.270.0070.07714.86
5.3.260.0000.08014.86
5.3.250.0070.06714.86
5.3.240.0030.06314.86
5.3.230.0030.06314.86
5.3.220.0130.05314.86
5.3.210.0030.07714.86
5.3.200.0000.06714.86
5.3.190.0000.07714.86
5.3.180.0030.06314.86
5.3.170.0070.07314.86
5.3.160.0000.06714.86
5.3.150.0030.06314.86
5.3.140.0100.06714.86
5.3.130.0030.06014.86
5.3.120.0070.07314.86
5.3.110.0030.07314.86
5.3.100.0030.06314.86
5.3.90.0030.07714.86
5.3.80.0000.07714.86
5.3.70.0030.07014.86
5.3.60.0030.06714.86
5.3.50.0070.07014.86
5.3.40.0030.07314.86
5.3.30.0030.07314.86
5.3.20.0100.06314.86
5.3.10.0200.05714.86
5.3.00.0000.07714.86
5.2.170.0000.06014.86
5.2.160.0070.04714.86
5.2.150.0000.07014.86
5.2.140.0000.06714.86
5.2.130.0100.05314.86
5.2.120.0000.06314.86
5.2.110.0030.06314.86
5.2.100.0030.06014.86
5.2.90.0070.05714.86
5.2.80.0030.05314.86
5.2.70.0070.05314.86
5.2.60.0000.05314.86
5.2.50.0070.05014.86
5.2.40.0030.05314.86
5.2.30.0070.05714.86
5.2.20.0070.05714.86
5.2.10.0030.06314.86
5.2.00.0070.05714.86
5.1.60.0100.04714.86
5.1.50.0070.04714.86
5.1.40.0030.05714.86
5.1.30.0000.06314.86
5.1.20.0030.05714.86
5.1.10.0030.05314.86
5.1.00.0000.05314.86
5.0.50.0030.04014.86
5.0.40.0030.04314.86
5.0.30.0030.06314.86
5.0.20.0030.04014.86
5.0.10.0030.03714.86
5.0.00.0030.05714.86
4.4.90.0030.03714.86
4.4.80.0000.04014.86
4.4.70.0000.03314.86
4.4.60.0000.02314.86
4.4.50.0030.03014.86
4.4.40.0070.05314.86
4.4.30.0070.03014.86
4.4.20.0030.03314.86
4.4.10.0000.04014.86
4.4.00.0070.04714.86
4.3.110.0000.02314.86
4.3.100.0070.02714.86
4.3.90.0030.02714.86
4.3.80.0000.05714.86
4.3.70.0030.03314.86
4.3.60.0000.03714.86
4.3.50.0000.03714.86
4.3.40.0000.05014.86
4.3.30.0000.03714.86
4.3.20.0100.03014.86
4.3.10.0000.03314.86
4.3.00.0000.03714.86

preferences:
52.29 ms | 401 KiB | 5 Q