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";

preferences:
49.78 ms | 402 KiB | 5 Q