3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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";
based on eOXFP
Output for 5.6.0 - 7.3.0alpha1
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 ( )