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.40.0080.00819.00
8.3.30.0070.00719.10
8.3.20.0030.00520.34
8.3.10.0080.00023.65
8.3.00.0040.00420.83
8.2.170.0120.00622.96
8.2.160.0090.00520.35
8.2.150.0000.00724.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00419.61
8.2.110.0090.00022.38
8.2.100.0030.00719.34
8.2.90.0060.00319.20
8.2.80.0050.00317.97
8.2.70.0030.00517.75
8.2.60.0050.00317.93
8.2.50.0050.00518.07
8.2.40.0090.00020.20
8.2.30.0000.00718.20
8.2.20.0040.00417.77
8.2.10.0050.00318.16
8.2.00.0040.00417.72
8.1.270.0060.00322.18
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0060.00323.83
8.1.230.0060.00619.15
8.1.220.0070.00317.77
8.1.210.0000.00818.77
8.1.200.0030.00717.48
8.1.190.0000.01017.22
8.1.180.0000.00818.10
8.1.170.0000.00818.63
8.1.160.0080.00021.95
8.1.150.0050.00218.64
8.1.140.0000.00717.55
8.1.130.0000.00717.50
8.1.120.0000.00717.57
8.1.110.0060.00317.46
8.1.100.0040.00417.54
8.1.90.0080.00017.53
8.1.80.0030.00517.57
8.1.70.0000.00717.43
8.1.60.0040.00417.73
8.1.50.0030.00717.70
8.1.40.0000.00817.68
8.1.30.0000.00817.70
8.1.20.0090.00017.73
8.1.10.0040.00417.62
8.1.00.0000.00817.64
8.0.300.0000.00818.77
8.0.290.0000.00816.75
8.0.280.0040.00418.55
8.0.270.0040.00417.16
8.0.260.0070.00016.97
8.0.250.0030.00517.14
8.0.240.0030.00617.17
8.0.230.0000.00717.07
8.0.220.0030.00317.04
8.0.210.0000.00716.96
8.0.200.0030.00317.02
8.0.190.0040.00417.03
8.0.180.0000.00917.01
8.0.170.0030.00516.92
8.0.160.0000.00716.93
8.0.150.0000.00716.94
8.0.140.0030.00616.95
8.0.130.0000.00613.41
8.0.120.0040.00416.84
8.0.110.0000.00716.89
8.0.100.0030.00517.10
8.0.90.0090.00017.00
8.0.80.0070.01016.92
8.0.70.0000.00816.98
8.0.60.0050.00217.11
8.0.50.0040.00416.98
8.0.30.0090.01017.14
8.0.20.0130.00617.40
8.0.10.0000.00717.15
8.0.00.0080.00916.91
7.4.330.0060.00015.00
7.4.320.0000.00716.71
7.4.300.0060.00016.62
7.4.290.0070.00016.82
7.4.280.0080.00316.74
7.4.270.0000.00716.72
7.4.260.0040.00416.73
7.4.250.0040.00416.68
7.4.240.0020.00516.82
7.4.230.0030.00316.76
7.4.220.0190.00316.75
7.4.210.0000.01416.89
7.4.200.0070.00016.69
7.4.160.0080.00816.66
7.4.150.0110.00817.40
7.4.140.0130.00617.86
7.4.130.0080.00816.79
7.4.120.0100.01116.69
7.4.110.0090.01216.64
7.4.100.0160.00716.41
7.4.90.0130.00716.69
7.4.80.0170.00419.39
7.4.70.0060.01116.89
7.4.60.0160.00616.64
7.4.50.0030.00616.61
7.4.40.0080.00816.58
7.4.30.0130.00316.73
7.4.10.0060.01215.27
7.4.00.0070.01114.97
7.3.330.0000.00613.37
7.3.320.0000.00613.33
7.3.310.0050.00316.43
7.3.300.0070.00016.26
7.3.290.0030.01316.40
7.3.280.0070.01016.38
7.3.270.0060.01217.40
7.3.260.0060.01216.66
7.3.250.0050.01316.74
7.3.240.0180.00616.74
7.3.230.0080.00816.70
7.3.210.0060.01216.50
7.3.200.0030.01719.39
7.3.190.0080.00816.61
7.3.180.0100.00716.33
7.3.170.0100.01016.64
7.3.160.0030.01316.47
7.3.130.0060.00614.70
7.3.120.0050.01015.26
7.3.110.0100.00715.07
7.3.100.0070.00714.97
7.3.90.0030.01214.95
7.3.80.0000.01814.50
7.3.70.0100.00615.04
7.3.60.0070.00714.80
7.3.50.0090.00015.05
7.3.40.0070.00714.62
7.3.30.0080.00615.01
7.3.20.0070.01016.90
7.3.10.0070.00616.71
7.3.00.0050.00916.70
7.2.330.0100.00716.46
7.2.320.0070.01016.84
7.2.310.0070.01116.64
7.2.300.0110.01116.79
7.2.290.0150.00316.84
7.2.260.0090.00915.25
7.2.250.0040.01615.07
7.2.240.0040.01115.25
7.2.230.0060.00614.93
7.2.220.0120.00014.97
7.2.210.0060.00315.34
7.2.200.0160.00015.00
7.2.190.0070.00715.25
7.2.180.0000.01315.03
7.2.170.0100.00315.24
7.2.160.0150.00015.10
7.2.150.0060.00616.88
7.2.140.0070.00717.15
7.2.130.0030.00817.19
7.2.120.0050.00717.05
7.2.110.0060.00716.92
7.2.100.0060.00517.03
7.2.90.0070.00717.06
7.2.80.0130.00017.08
7.2.70.0090.00416.93
7.2.60.0040.00817.03
7.2.50.0080.00516.91
7.2.40.0050.00617.18
7.2.30.0040.00916.96
7.2.20.0030.01017.02
7.2.10.0050.01017.06
7.2.00.0050.00717.93
7.1.330.0060.00915.95
7.1.320.0070.00415.96
7.1.310.0110.00415.93
7.1.300.0090.00616.07
7.1.290.0070.00715.88
7.1.280.0060.00915.72
7.1.270.0030.01016.04
7.1.260.0030.01015.86
7.1.250.0030.01015.78
7.1.240.0000.01315.63
7.1.230.0060.00616.05
7.1.220.0030.01015.92
7.1.210.0050.00515.84
7.1.200.0110.00315.90
7.1.190.0060.01215.96
7.1.180.0040.00716.02
7.1.170.0030.01016.01
7.1.160.0090.00315.92
7.1.150.0030.01015.97
7.1.140.0070.00715.69
7.1.130.0040.01115.91
7.1.120.0070.00715.82
7.1.110.0030.00915.99
7.1.100.0030.00917.02
7.1.90.0060.00616.00
7.1.80.0070.00315.75
7.1.70.0020.00716.40
7.1.60.0040.00916.56
7.1.50.0040.01216.58
7.1.40.0040.00815.81
7.1.30.0000.01415.86
7.1.20.0080.00015.74
7.1.10.0040.00415.90
7.1.00.0070.03719.23
7.0.330.0030.00915.20
7.0.320.0030.01015.53
7.0.310.0000.01415.50
7.0.300.0030.00915.59
7.0.290.0130.00015.75
7.0.280.0060.00615.59
7.0.270.0100.00315.38
7.0.260.0060.00315.72
7.0.250.0060.00615.54
7.0.240.0030.01215.46
7.0.230.0030.00715.19
7.0.220.0090.00315.71
7.0.210.0100.00315.56
7.0.200.0040.00816.21
7.0.190.0000.00815.25
7.0.180.0000.00915.54
7.0.170.0030.00915.22
7.0.160.0060.00915.53
7.0.150.0040.00815.63
7.0.140.0030.04118.74
7.0.130.0060.00815.55
7.0.120.0100.00715.38
7.0.110.0080.03917.70
7.0.100.0140.04017.68
7.0.90.0120.04017.72
7.0.80.0100.02317.70
7.0.70.0080.02317.72
7.0.60.0000.02717.56
7.0.50.0050.02417.70
7.0.40.0050.02216.67
7.0.30.0070.02416.60
7.0.20.0060.02116.70
7.0.10.0020.02716.72
7.0.00.0070.02516.65
5.6.400.0050.00514.37
5.6.390.0030.01014.11
5.6.380.0000.01014.61
5.6.370.0060.01214.47
5.6.360.0060.00614.37
5.6.350.0090.00013.82
5.6.340.0030.00714.25
5.6.330.0100.00314.61
5.6.320.0030.01014.45
5.6.310.0040.01113.98
5.6.300.0040.01114.64
5.6.290.0060.00614.38
5.6.280.0020.04217.74
5.6.270.0030.01014.59
5.6.260.0110.04317.53
5.6.250.0050.05017.60
5.6.240.0060.03117.55
5.6.230.0090.02517.53
5.6.220.0070.02517.46
5.6.210.0080.01917.38
5.6.200.0070.02517.25
5.6.190.0050.02317.56
5.6.180.0090.01817.59
5.6.170.0070.02517.50
5.6.160.0050.02017.59
5.6.150.0090.02017.59
5.6.140.0070.02717.52
5.6.130.0050.02317.46
5.6.120.0030.02217.68
5.6.110.0070.03717.50
5.6.100.0020.02717.52
5.6.90.0060.02017.37
5.6.80.0020.02217.37
5.6.70.0020.02617.25
5.6.60.0030.03917.10
5.6.50.0050.02417.21
5.6.40.0080.02316.97
5.6.30.0050.02517.18
5.6.20.0060.02317.13
5.6.10.0030.02517.25
5.6.00.0060.02117.07
5.5.380.0050.02317.33
5.5.370.0120.03717.44
5.5.360.0030.03517.30
5.5.350.0000.03317.50
5.5.340.0120.02017.65
5.5.330.0050.02317.71
5.5.320.0060.02117.45
5.5.310.0050.02417.39
5.5.300.0050.02517.59
5.5.290.0030.02717.48
5.5.280.0000.02817.57
5.5.270.0070.02217.52
5.5.260.0010.02717.49
5.5.250.0000.02717.49
5.5.240.0030.02517.20
5.5.230.0030.03017.10
5.5.220.0020.02717.12
5.5.210.0030.02717.27
5.5.200.0100.01917.22
5.5.190.0080.02217.09
5.5.180.0090.01917.11
5.5.170.0030.01414.31
5.5.160.0020.02717.29
5.5.150.0050.02217.24
5.5.140.0100.01817.07
5.5.130.0030.02817.34
5.5.120.0050.04117.06
5.5.110.0070.02217.13
5.5.100.0050.04317.25
5.5.90.0050.04717.12
5.5.80.0090.03917.05
5.5.70.0030.04317.28
5.5.60.0070.04217.03
5.5.50.0110.03617.13
5.5.40.0070.04317.04
5.5.30.0080.04117.19
5.5.20.0050.04317.05
5.5.10.0090.04117.19
5.5.00.0080.03917.04
5.4.450.0060.01815.36
5.4.440.0020.02415.37
5.4.430.0070.02215.37
5.4.420.0030.02315.36
5.4.410.0050.02014.97
5.4.400.0110.01315.07
5.4.390.0000.02814.95
5.4.380.0020.02015.15
5.4.370.0020.02015.08
5.4.360.0020.02715.15
5.4.350.0050.03515.28
5.4.340.0070.02214.99
5.4.330.0090.00311.10
5.4.320.0040.03715.14
5.4.310.0060.02115.07
5.4.300.0090.01615.08
5.4.290.0080.01815.09
5.4.280.0060.02715.14
5.4.270.0010.02815.15
5.4.260.0050.04015.21
5.4.250.0080.03515.20
5.4.240.0050.04014.96
5.4.230.0060.04015.01
5.4.220.0080.03815.14
5.4.210.0050.03715.13
5.4.200.0080.03914.90
5.4.190.0030.04015.01
5.4.180.0050.04415.04
5.4.170.0050.02415.03
5.4.160.0020.04515.08
5.4.150.0060.04115.02
5.4.140.0040.04213.85
5.4.130.0060.03313.75
5.4.120.0030.04113.69
5.4.110.0070.04013.89
5.4.100.0060.03113.87
5.4.90.0080.03713.80
5.4.80.0070.03813.86
5.4.70.0050.03313.94
5.4.60.0020.04013.78
5.4.50.0110.03113.82
5.4.40.0060.04113.72
5.4.30.0070.02313.66
5.4.20.0040.04013.82
5.4.10.0070.04113.85
5.4.00.0070.02313.42
5.3.290.0030.04314.70
5.3.280.0030.08314.68
5.3.270.0100.07014.60
5.3.260.0130.06714.60
5.3.250.0100.06714.63
5.3.240.0030.07714.63
5.3.230.0100.08014.45
5.3.220.0030.07314.64
5.3.210.0100.07314.57
5.3.200.0030.08014.56
5.3.190.0130.05314.59
5.3.180.0030.07314.65
5.3.170.0030.07714.52
5.3.160.0130.06014.79
5.3.150.0070.08014.64
5.3.140.0070.04714.54
5.3.130.0100.08014.63
5.3.120.0100.07014.63
5.3.110.0070.07014.50
5.3.100.0130.06714.04
5.3.90.0100.06714.16
5.3.80.0070.08014.02
5.3.70.0030.07014.04
5.3.60.0100.06714.08
5.3.50.0200.05713.90
5.3.40.0200.06313.90
5.3.30.0070.06313.93
5.3.20.0100.06713.55
5.3.10.0070.06313.72
5.3.00.0100.03313.64
5.2.170.0130.05312.08
5.2.160.0030.03312.08
5.2.150.0030.06312.08
5.2.140.0100.05312.08
5.2.130.0070.05712.08
5.2.120.0070.06012.08
5.2.110.0030.06012.08
5.2.100.0070.05012.08
5.2.90.0070.05712.08
5.2.80.0000.04712.08
5.2.70.0130.05312.08
5.2.60.0000.05012.08
5.2.50.0000.06312.08
5.2.40.0030.05712.08
5.2.30.0100.05312.08
5.2.20.0070.06012.08
5.2.10.0030.06712.08
5.2.00.0070.05312.08
5.1.60.0030.05012.08
5.1.50.0030.03712.08
5.1.40.0070.05312.08
5.1.30.0000.05312.08
5.1.20.0000.06012.08
5.1.10.0030.05712.08
5.1.00.0030.05312.08
5.0.50.0070.02312.08
5.0.40.0070.03312.08
5.0.30.0000.07012.08
5.0.20.0030.04012.08
5.0.10.0070.03712.08
5.0.00.0100.04012.08
4.4.90.0000.03712.08
4.4.80.0030.03312.08
4.4.70.0000.03712.08
4.4.60.0070.03012.08
4.4.50.0030.03712.08
4.4.40.0030.05312.08
4.4.30.0030.03312.08
4.4.20.0070.03012.08
4.4.10.0030.03012.08
4.4.00.0030.03712.08
4.3.110.0000.03712.08
4.3.100.0070.03012.08
4.3.90.0030.03312.08
4.3.80.0030.04312.08
4.3.70.0030.03712.08
4.3.60.0000.03712.08
4.3.50.0000.03312.08
4.3.40.0030.04012.08
4.3.30.0000.03712.08
4.3.20.0000.03012.08
4.3.10.0000.03712.08
4.3.00.0000.03712.08

preferences:
45.09 ms | 400 KiB | 5 Q