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.0090.00618.55
8.3.50.0090.00922.17
8.3.40.0040.01418.70
8.3.30.0140.00018.92
8.3.20.0050.00318.77
8.3.10.0040.00421.09
8.3.00.0030.00623.55
8.2.180.0100.01316.50
8.2.170.0130.00722.96
8.2.160.0000.01522.43
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0000.00726.16
8.2.120.0080.00021.23
8.2.110.0090.00020.52
8.2.100.0040.00817.91
8.2.90.0040.00419.08
8.2.80.0000.00818.04
8.2.70.0040.00417.88
8.2.60.0060.00317.93
8.2.50.0000.00818.07
8.2.40.0000.00818.19
8.2.30.0030.00519.76
8.2.20.0040.00417.69
8.2.10.0030.00617.72
8.2.00.0040.00417.91
8.1.280.0090.00925.92
8.1.270.0000.00823.99
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00322.59
8.1.230.0100.00020.87
8.1.220.0090.00018.77
8.1.210.0040.00418.84
8.1.200.0090.00017.25
8.1.190.0060.00317.17
8.1.180.0080.00018.10
8.1.170.0030.00518.54
8.1.160.0020.00518.86
8.1.150.0050.00318.64
8.1.140.0030.00517.50
8.1.130.0000.00717.85
8.1.120.0030.00417.56
8.1.110.0050.00217.56
8.1.100.0030.00517.47
8.1.90.0040.00417.50
8.1.80.0040.00417.61
8.1.70.0000.00917.50
8.1.60.0060.00317.74
8.1.50.0040.00417.62
8.1.40.0050.00317.70
8.1.30.0000.00817.81
8.1.20.0030.00517.71
8.1.10.0000.00717.74
8.1.00.0000.00817.64
8.0.300.0040.00419.94
8.0.290.0060.00317.18
8.0.280.0070.00018.54
8.0.270.0000.00717.28
8.0.260.0000.00916.95
8.0.250.0000.00817.16
8.0.240.0060.00317.13
8.0.230.0030.00317.01
8.0.220.0030.00316.91
8.0.210.0070.00017.05
8.0.200.0000.00717.07
8.0.190.0000.00716.91
8.0.180.0070.00317.01
8.0.170.0030.00317.03
8.0.160.0000.00717.09
8.0.150.0040.00416.97
8.0.140.0070.00017.01
8.0.130.0030.00313.39
8.0.120.0060.00316.93
8.0.110.0050.00216.84
8.0.100.0040.00416.89
8.0.90.0080.00017.06
8.0.80.0060.01016.98
8.0.70.0040.00416.95
8.0.60.0030.00517.05
8.0.50.0000.00817.00
8.0.30.0060.01317.44
8.0.20.0100.00917.40
8.0.10.0080.00017.10
8.0.00.0110.01017.06
7.4.330.0000.00615.05
7.4.320.0000.00616.69
7.4.300.0000.00616.86
7.4.290.0030.00316.91
7.4.280.0040.00816.67
7.4.270.0030.00316.86
7.4.260.0000.00513.42
7.4.250.0040.00416.68
7.4.240.0030.00316.68
7.4.230.0040.00416.52
7.4.220.0060.01216.91
7.4.210.0060.00816.82
7.4.200.0000.00816.63
7.4.190.0000.00716.78
7.4.160.0050.01216.91
7.4.150.0080.01117.40
7.4.140.0130.00717.86
7.4.130.0120.00816.75
7.4.120.0110.00616.73
7.4.110.0110.01116.72
7.4.100.0040.01216.73
7.4.90.0060.01216.84
7.4.80.0070.01119.37
7.4.70.0150.00416.86
7.4.60.0090.00916.81
7.4.50.0000.00516.68
7.4.40.0060.01222.27
7.4.30.0100.00716.84
7.4.00.0080.00915.28
7.3.330.0000.00513.39
7.3.320.0000.00713.15
7.3.310.0040.00416.42
7.3.300.0030.00316.26
7.3.290.0060.00916.42
7.3.280.0060.01116.39
7.3.270.0110.00617.40
7.3.260.0080.01218.24
7.3.250.0080.01116.58
7.3.240.0040.01416.75
7.3.230.0120.00616.77
7.3.210.0100.01016.48
7.3.200.0110.00519.39
7.3.190.0070.01016.50
7.3.180.0040.01316.77
7.3.170.0090.00916.45
7.3.160.0030.01316.69
7.3.120.0080.00914.80
7.3.110.0060.01214.93
7.3.100.0070.01014.67
7.3.90.0030.00914.93
7.3.80.0030.01314.85
7.3.70.0120.00614.92
7.3.60.0090.00315.04
7.3.50.0110.00715.01
7.3.40.0100.00314.99
7.3.30.0060.00615.03
7.3.20.0050.00516.79
7.3.10.0110.00316.66
7.3.00.0110.00316.81
7.2.330.0130.00616.76
7.2.320.0100.01116.89
7.2.310.0140.00916.66
7.2.300.0110.00716.83
7.2.290.0060.01216.78
7.2.250.0070.01115.21
7.2.240.0040.01515.34
7.2.230.0030.01215.09
7.2.220.0100.00315.46
7.2.210.0030.01014.96
7.2.200.0060.00915.32
7.2.190.0060.00915.04
7.2.180.0000.01615.30
7.2.170.0140.00315.11
7.2.160.0090.00915.24
7.2.150.0060.00317.20
7.2.140.0070.01017.09
7.2.130.0080.00917.04
7.2.120.0070.00716.90
7.2.110.0030.01317.11
7.2.100.0070.00717.02
7.2.90.0080.00517.07
7.2.80.0090.00717.15
7.2.70.0050.00517.05
7.2.60.0100.00716.93
7.2.50.0000.01317.09
7.2.40.0060.00616.97
7.2.30.0070.00816.96
7.2.20.0130.00217.29
7.2.10.0040.00817.05
7.2.00.0030.01017.82
7.1.330.0040.01416.00
7.1.320.0060.00916.07
7.1.310.0070.00716.16
7.1.300.0070.00716.11
7.1.290.0050.00515.96
7.1.280.0040.01115.81
7.1.270.0040.00815.89
7.1.260.0070.01016.10
7.1.250.0010.01015.82
7.1.240.0070.00316.06
7.1.230.0070.00715.66
7.1.220.0120.00415.85
7.1.210.0090.00316.02
7.1.200.0030.01415.89
7.1.190.0050.00515.99
7.1.180.0030.01315.96
7.1.170.0070.00715.89
7.1.160.0070.00716.05
7.1.150.0070.00415.82
7.1.140.0070.00415.68
7.1.130.0000.01315.98
7.1.120.0060.00315.91
7.1.110.0030.01015.75
7.1.100.0020.01017.01
7.1.90.0090.00315.75
7.1.80.0040.01115.87
7.1.70.0020.01016.61
7.1.60.0020.00916.66
7.1.50.0070.01116.56
7.1.40.0060.00915.59
7.1.30.0100.00315.74
7.1.20.0110.00416.03
7.1.10.0060.00615.96
7.1.00.0100.02219.10
7.0.330.0080.00815.56
7.0.320.0060.00915.55
7.0.310.0100.00715.30
7.0.300.0040.00415.68
7.0.290.0000.01215.27
7.0.280.0000.01515.57
7.0.270.0000.01315.52
7.0.260.0060.00615.35
7.0.250.0030.01415.64
7.0.240.0040.01115.46
7.0.230.0000.01215.59
7.0.220.0000.01415.24
7.0.210.0030.00615.45
7.0.200.0030.01216.08
7.0.190.0030.01315.23
7.0.180.0070.00715.57
7.0.170.0000.01115.65
7.0.160.0050.00315.52
7.0.150.0030.00615.61
7.0.140.0040.04118.85
7.0.130.0030.01415.38
7.0.120.0040.00815.29
7.0.110.0000.01515.51
7.0.100.0060.00315.52
7.0.90.0000.01315.39
7.0.80.0090.00315.43
7.0.70.0000.01515.42
7.0.60.0050.04118.66
7.0.50.0090.04218.80
7.0.40.0020.03316.87
7.0.30.0050.04016.94
7.0.20.0050.04716.77
7.0.10.0110.04016.85
7.0.00.0080.04616.71
5.6.400.0070.01014.25
5.6.390.0060.01014.30
5.6.380.0030.01414.57
5.6.370.0030.01014.35
5.6.360.0110.00914.70
5.6.350.0080.00014.37
5.6.340.0080.00814.17
5.6.330.0040.01114.44
5.6.320.0030.00614.10
5.6.310.0060.00614.26
5.6.300.0000.01214.00
5.6.290.0000.01713.95
5.6.280.0100.00614.53
5.6.270.0060.00914.31
5.6.260.0090.00414.25
5.6.250.0060.00914.18
5.6.240.0000.01314.59
5.6.230.0000.01414.21
5.6.220.0070.01014.57
5.6.210.0060.04417.43
5.6.200.0090.03017.58
5.6.190.0120.03817.68
5.6.180.0100.04017.55
5.6.170.0070.04017.62
5.6.160.0080.02317.76
5.6.150.0140.03317.56
5.6.140.0030.04617.63
5.6.130.0030.04817.70
5.6.120.0070.04317.57
5.6.110.0060.04517.71
5.6.100.0100.04217.66
5.6.90.0030.05017.80
5.6.80.0050.04017.38
5.6.70.0030.03817.30
5.6.60.0040.03417.27
5.6.50.0090.04017.36
5.6.40.0090.04017.41
5.6.30.0130.03317.47
5.6.20.0040.04117.40
5.6.10.0020.04917.22
5.6.00.0070.04217.26
5.5.380.0120.00314.14
5.5.370.0090.00014.43
5.5.360.0150.00014.05
5.5.350.0020.04717.27
5.5.340.0070.04317.42
5.5.330.0030.04817.41
5.5.320.0050.04717.61
5.5.310.0050.04217.46
5.5.300.0080.03817.67
5.5.290.0040.03617.59
5.5.280.0030.04317.49
5.5.270.0050.04717.65
5.5.260.0030.04317.50
5.5.250.0030.04717.39
5.5.240.0020.04517.13
5.5.230.0070.04017.13
5.5.220.0020.04217.15
5.5.210.0050.04017.30
5.5.200.0090.02117.15
5.5.190.0030.04617.13
5.5.180.0040.04717.09
5.5.170.0100.00314.25
5.5.160.0030.04516.95
5.5.150.0080.04017.14
5.5.140.0050.04217.29
5.5.130.0050.04117.30
5.5.120.0000.04417.05
5.5.110.0080.04017.16
5.5.100.0020.04417.11
5.5.90.0080.04017.12
5.5.80.0080.03917.04
5.5.70.0040.04017.11
5.5.60.0100.03917.07
5.5.50.0060.04416.93
5.5.40.0050.04017.02
5.5.30.0090.02817.13
5.5.20.0100.03517.11
5.5.10.0070.04017.15
5.5.00.0050.04217.20
5.4.450.0050.03515.34
5.4.440.0060.04115.26
5.4.430.0030.04015.21
5.4.420.0080.02715.17
5.4.410.0060.03615.19
5.4.400.0030.03015.02
5.4.390.0030.03715.02
5.4.380.0010.04415.02
5.4.370.0090.03315.03
5.4.360.0060.04115.03
5.4.350.0080.03815.01
5.4.340.0070.03515.19
5.4.330.0060.00610.98
5.4.320.0120.03215.19
5.4.310.0030.03815.26
5.4.300.0000.04415.00
5.4.290.0000.04415.13
5.4.280.0030.03515.12
5.4.270.0080.03515.07
5.4.260.0030.04315.12
5.4.250.0060.04114.96
5.4.240.0040.04114.99
5.4.230.0030.04315.09
5.4.220.0030.04115.16
5.4.210.0090.03015.08
5.4.200.0090.02815.14
5.4.190.0050.04015.13
5.4.180.0020.04515.09
5.4.170.0050.03815.18
5.4.160.0050.04015.02
5.4.150.0020.03715.21
5.4.140.0030.04013.86
5.4.130.0050.03013.70
5.4.120.0020.04113.77
5.4.110.0020.04013.79
5.4.100.0080.03813.78
5.4.90.0050.03513.72
5.4.80.0020.04313.81
5.4.70.0030.03313.66
5.4.60.0020.04213.67
5.4.50.0030.04513.69
5.4.40.0030.04113.80
5.4.30.0020.04113.73
5.4.20.0050.02113.65
5.4.10.0030.02013.75
5.4.00.0020.04213.42
5.3.290.0010.04312.83
5.3.280.0030.04312.84
5.3.270.0010.03812.79
5.3.260.0020.02812.82
5.3.250.0080.03712.80
5.3.240.0020.03012.82
5.3.230.0040.03412.85
5.3.220.0020.03812.76
5.3.210.0030.03812.78
5.3.200.0030.04212.80
5.3.190.0020.04212.80
5.3.180.0050.03512.80
5.3.170.0070.03512.79
5.3.160.0030.04212.78
5.3.150.0120.03212.80
5.3.140.0030.04012.82
5.3.130.0060.04212.74
5.3.120.0050.02512.74
5.3.110.0040.02012.79
5.3.100.0050.03312.51
5.3.90.0070.03512.52
5.3.80.0050.04012.51
5.3.70.0050.04012.54
5.3.60.0020.04112.55
5.3.50.0050.04012.45
5.3.40.0050.03312.50
5.3.30.0050.02312.47
5.3.20.0050.03512.27
5.3.10.0020.03212.34
5.3.00.0090.02712.33
5.2.170.0030.05711.13
5.2.160.0030.04711.13
5.2.150.0170.05011.13
5.2.140.0000.05011.23
5.2.130.0030.04711.13
5.2.120.0000.06011.14
5.2.110.0030.06311.10
5.2.100.0030.05310.95
5.2.90.0070.04711.20
5.2.80.0030.06011.08
5.2.70.0000.06011.08
5.2.60.0030.06010.94
5.2.50.0070.06011.07
5.2.40.0000.04310.85
5.2.30.0000.03710.83
5.2.20.0000.04711.07
5.2.10.0030.05710.93
5.2.00.0070.06010.56
5.1.60.0030.05310.03
5.1.50.0000.0509.82
5.1.40.0070.0509.81
5.1.30.0000.05710.39
5.1.20.0030.05710.47
5.1.10.0000.04710.16
5.1.00.0030.05010.14
5.0.50.0000.0439.56
5.0.40.0000.0439.56
5.0.30.0000.0579.56
5.0.20.0030.0439.56
5.0.10.0000.0379.56
5.0.00.0000.0679.56
4.4.90.0000.0339.56
4.4.80.0000.0379.56
4.4.70.0030.0209.56
4.4.60.0030.0379.56
4.4.50.0030.0309.56
4.4.40.0000.0539.56
4.4.30.0000.0309.56
4.4.20.0030.0339.56
4.4.10.0000.0379.56
4.4.00.0000.0479.56
4.3.110.0000.0339.56
4.3.100.0030.0279.56
4.3.90.0000.0379.56
4.3.80.0030.0439.56
4.3.70.0030.0339.56
4.3.60.0070.0279.56
4.3.50.0000.0379.56
4.3.40.0000.0539.56
4.3.30.0030.0339.56
4.3.20.0000.0379.56
4.3.10.0000.0379.56
4.3.00.0070.0309.56

preferences:
37.23 ms | 401 KiB | 5 Q