3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $test=array("abcd/abcd_.mp3", "abcd", "asdasd/abcd.mp3", "abcd.", "blahahbasdabcd"); foreach ($test as $t) echo "$t => " . preg_replace("/(abcd([^_.])|abcd$)/x", "XXXXX" . "\${1}", $t) . "\n";
Output for 4.3.0 - 7.1.0
abcd/abcd_.mp3 => XXXXXabcd/abcd_.mp3 abcd => XXXXXabcd asdasd/abcd.mp3 => asdasd/abcd.mp3 abcd. => abcd. blahahbasdabcd => blahahbasdXXXXXabcd