3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern='/^(?=(.*[a-z])+)(?=(.*[A-Z]){2,})(?=(.*[0-9])+)(?=(.*[&#@=€$%*?\/:!\-+])+)([a-zA-Z0-9&#@=€$%*?\/:!\-+]){8,}$/'; echo "Using one byte from €:\\xe2 \\x82 \\xac", PHP_EOL; var_dump (preg_match($pattern, "aAB0\xe2ABC")); var_dump (preg_match($pattern, "aAB0\x82ABC")); var_dump (preg_match($pattern, "aAB0\xacABC")); echo "Avec €:", PHP_EOL; var_dump (preg_match($pattern, "aAB0€ABC")); echo PHP_EOL, "Since the regex engine reads the string byte by byte, the length of the string isn't what you expected.", PHP_EOL; var_dump(preg_match($pattern, "€aBC01")); ########################################################### echo PHP_EOL,PHP_EOL,'With the (*UTF8) verb',PHP_EOL,'###########################################################',PHP_EOL; $pattern='/(*UTF8)^(?=(.*[a-z])+)(?=(.*[A-Z]){2,})(?=(.*[0-9])+)(?=(.*[&#@=€$%*?\/:!\-+])+)([a-zA-Z0-9&#@=€$%*?\/:!\-+]){8,}$/'; echo "(*UTF8): Now € is seen as an character, no more as a set of bytes", PHP_EOL; var_dump (preg_match($pattern, "aAB0\xe2ABC")); var_dump (preg_match($pattern, "aAB0\x82ABC")); var_dump (preg_match($pattern, "aAB0\xacABC")); echo "Avec €:", PHP_EOL; var_dump (preg_match($pattern, "aAB0€ABC")); echo PHP_EOL, "Test with '€aBC01'. Now the regex engine reads the string unicode point by unicode point (encoded in UTF-8), the length of the string is the number of characters. Since there's less than 8 characters the pattern fails..", PHP_EOL; var_dump(preg_match($pattern, "€aBC01")); ########################################################### echo PHP_EOL,PHP_EOL, 'With the u modifier', PHP_EOL,'###########################################################',PHP_EOL; $pattern='/^(?=(.*[a-z])+)(?=(.*[A-Z]){2,})(?=(.*[0-9])+)(?=(.*[&#@=€$%*?\/:!\-+])+)([a-zA-Z0-9&#@=€$%*?\/:!\-+]){8,}$/u'; echo "The u modifier that is synonym of (*UTF8)(*UCP)", PHP_EOL; var_dump (preg_match($pattern, "aAB0\xe2ABC")); var_dump (preg_match($pattern, "aAB0\x82ABC")); var_dump (preg_match($pattern, "aAB0\xacABC")); echo "Avec €:", PHP_EOL; var_dump (preg_match($pattern, "aAB0€ABC")); echo PHP_EOL, "Test with '€aBC01'", PHP_EOL; var_dump(preg_match($pattern, "€aBC01"));

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.70.0090.00616.88
8.3.60.0040.01218.80
8.3.50.0070.00718.33
8.3.40.0090.00619.22
8.3.30.0090.00619.22
8.3.20.0050.00319.27
8.3.10.0000.00823.90
8.3.00.0040.00423.66
8.2.190.0130.00317.00
8.2.180.0130.01018.66
8.2.170.0120.00322.96
8.2.160.0130.00319.42
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0080.00019.61
8.2.110.0070.00321.38
8.2.100.0090.00318.16
8.2.90.0090.00018.34
8.2.80.0080.00017.97
8.2.70.0030.00617.88
8.2.60.0000.00818.18
8.2.50.0000.00818.13
8.2.40.0000.00918.47
8.2.30.0050.00318.34
8.2.20.0030.00618.41
8.2.10.0000.00818.23
8.2.00.0070.00019.52
8.1.280.0120.00325.92
8.1.270.0040.00420.25
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00719.46
8.1.230.0060.00622.96
8.1.220.0030.00617.80
8.1.210.0030.00918.89
8.1.200.0070.00317.60
8.1.190.0000.00917.60
8.1.180.0040.00418.10
8.1.170.0030.00519.02
8.1.160.0060.00318.98
8.1.150.0040.00419.10
8.1.140.0000.00819.21
8.1.130.0000.00719.29
8.1.120.0080.00017.73
8.1.110.0030.00517.80
8.1.100.0030.00617.71
8.1.90.0040.00417.81
8.1.80.0050.00317.82
8.1.70.0000.00817.80
8.1.60.0060.00317.94
8.1.50.0000.00917.86
8.1.40.0090.00017.88
8.1.30.0040.00418.09
8.1.20.0000.00817.97
8.1.10.0030.00617.82
8.1.00.0060.00317.90
8.0.300.0000.00820.23
8.0.290.0030.00616.99
8.0.280.0000.00718.72
8.0.270.0000.00717.46
8.0.260.0030.00517.53
8.0.250.0070.00017.33
8.0.240.0000.00717.40
8.0.230.0030.00617.40
8.0.220.0040.00417.30
8.0.210.0030.00517.23
8.0.200.0070.00017.35
8.0.190.0040.00417.35
8.0.180.0000.00817.32
8.0.170.0000.00917.33
8.0.160.0060.00317.21
8.0.150.0040.00417.25
8.0.140.0030.00517.27
8.0.130.0000.00813.70
8.0.120.0080.00017.25
8.0.110.0050.00317.10
8.0.100.0040.00417.19
8.0.90.0040.00417.18
8.0.80.0050.01317.24
8.0.70.0000.00817.17
8.0.60.0080.00017.13
8.0.50.0070.00017.39
8.0.30.0140.00617.38
8.0.20.0110.01017.59
8.0.10.0000.00717.23
8.0.00.0150.00417.23
7.4.330.0060.00015.55
7.4.320.0030.00317.03
7.4.300.0050.00216.91
7.4.290.0050.00216.82
7.4.280.0000.00916.98
7.4.270.0080.00017.02
7.4.260.0050.00316.76
7.4.250.0000.00816.88
7.4.240.0040.00416.91
7.4.230.0050.00317.11
7.4.220.0030.00616.82
7.4.210.0120.00417.07
7.4.200.0040.00416.95
7.4.160.0120.00916.86
7.4.140.0120.00717.86
7.4.130.0150.01217.00
7.4.120.0080.01116.96
7.4.110.0000.01716.93
7.4.100.0090.01516.86
7.4.90.0120.01216.72
7.4.80.0060.01619.39
7.4.70.0060.01217.08
7.4.60.0130.01016.92
7.4.50.0070.00616.94
7.4.40.0120.00916.82
7.4.00.0050.01015.18
7.3.330.0000.00513.50
7.3.320.0000.00713.33
7.3.310.0000.00916.54
7.3.300.0070.00016.56
7.3.290.0070.00016.63
7.3.280.0120.00816.62
7.3.260.0130.00816.61
7.3.240.0090.01016.79
7.3.230.0080.01216.93
7.3.210.0080.01116.54
7.3.200.0110.01016.83
7.3.190.0140.00316.98
7.3.180.0060.01216.92
7.3.170.0050.01216.63
7.3.160.0160.00316.52
7.3.120.0070.01015.02
7.3.110.0070.01315.02
7.3.100.0070.01015.34
7.3.90.0060.01314.78
7.3.80.0030.01415.00
7.3.70.0000.01415.09
7.3.60.0040.01115.22
7.3.50.0100.01015.15
7.3.40.0080.00615.27
7.3.30.0000.01514.98
7.3.20.0090.00617.00
7.3.10.0100.00416.58
7.3.00.0100.00616.65
7.2.330.0160.00316.71
7.2.320.0090.00916.82
7.2.310.0100.01316.80
7.2.300.0110.01116.62
7.2.290.0080.01716.80
7.2.250.0110.00715.32
7.2.240.0100.01015.21
7.2.230.0110.00715.05
7.2.220.0080.00315.40
7.2.210.0060.00915.06
7.2.200.0040.01215.19
7.2.190.0040.00715.11
7.2.180.0100.00614.96
7.2.170.0120.00315.35
7.2.80.0580.00614.81
7.2.70.0510.01615.32
7.2.60.0400.01315.41
7.2.50.0610.01315.26
7.2.40.0760.00715.15
7.2.30.0420.00715.09
7.2.20.0430.00615.39
7.2.10.0610.01915.11
7.2.00.0510.01615.47
7.1.330.0070.01015.93
7.1.320.0030.01315.95
7.1.310.0070.00715.66
7.1.300.0040.01115.99
7.1.290.0070.01015.80
7.1.280.0040.01416.05
7.1.270.0070.00715.76
7.1.260.0060.01015.84
7.1.200.0060.00615.88
7.1.190.0450.01013.91
7.1.180.0480.00913.92
7.1.170.0550.01013.85
7.1.160.0410.01514.19
7.1.150.0480.00714.05
7.1.140.0400.01014.24
7.1.130.0440.00913.93
7.1.120.0550.01014.10
7.1.110.0740.00714.27
7.1.100.0830.01013.87
7.1.90.0600.00614.08
7.1.80.0500.01213.95
7.1.70.0450.00914.06
7.1.60.0730.00632.23
7.1.50.0810.00632.24
7.1.40.0780.01632.13
7.1.30.1030.00732.00
7.1.20.0710.02232.07
7.1.10.0620.01014.09
7.1.00.0510.01014.07

preferences:
50.53 ms | 401 KiB | 5 Q