3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = '/(\b\w+\b).*\b\1\b.*/i'; //should match $string = "TheseCharacters, I really enjoy TheseCharacters"; $result = preg_match($pattern, $string, $matches); echo "String 1 matches {$result} times: ".print_r($matches,true)."\n"; //should match $string = "TheseCharacters, I really enjoy TheseCharacters"; $result = preg_match($pattern, $string, $matches); echo "String 1 matches {$result} times: ".print_r($matches,true)."\n"; //match only with case insensitive flag, not an exact match in case $string = "TheseCharacters, I really enjoy TheseCharacters and some others"; $result = preg_match($pattern, $string, $matches); echo "String 2 matches {$result} times: ".print_r($matches,true)."\n"; //no match, TheseCharacters has been changed to TheseLetters $string = "TheseCharacters, I really enjoy TheseLetters"; $result = preg_match($pattern, $string, $matches); echo "String 3 matches {$result} times: ".print_r($matches,true)."\n"; //no match, additional letters has been added to TheseCharacters $string = "TheseCharacters, I really enjoy TheseCharactersasdf"; $result = preg_match($pattern, $string, $matches); echo "String 4 matches {$result} times: ".print_r($matches,true)."\n";
Output for 5.6.0 - 5.6.26, 7.0.0 - 7.0.11, 7.1.0, 7.2.29 - 7.2.33, 7.3.16 - 7.3.33, 7.4.3 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
String 1 matches 1 times: Array ( [0] => TheseCharacters, I really enjoy TheseCharacters [1] => TheseCharacters ) String 1 matches 1 times: Array ( [0] => TheseCharacters, I really enjoy TheseCharacters [1] => TheseCharacters ) String 2 matches 1 times: Array ( [0] => TheseCharacters, I really enjoy TheseCharacters and some others [1] => TheseCharacters ) String 3 matches 0 times: Array ( ) String 4 matches 0 times: Array ( )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 String 1 matches 1 times: Array ( [0] => TheseCharacters, I really enjoy TheseCharacters [1] => TheseCharacters ) String 1 matches 1 times: Array ( [0] => TheseCharacters, I really enjoy TheseCharacters [1] => TheseCharacters ) String 2 matches 1 times: Array ( [0] => TheseCharacters, I really enjoy TheseCharacters and some others [1] => TheseCharacters ) String 3 matches 0 times: Array ( ) String 4 matches 0 times: Array ( )

preferences:
161.72 ms | 403 KiB | 179 Q