3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test=array("abcd/abcd_.mp3", "abcd", "asdasd/abcd.mp3", "abcd.", "blahahbasdabcd"); $searchTerm = "abcd"; $replaceTerm = "XXXX"; foreach ($test as $t) echo "$t => " . preg_replace("/(". preg_quote($searchTerm) . "([^_.])|". preg_quote($searchTerm) . $)/x", ". preg_quote($replaceTerm) . . "\${2}", $t) . "\n";
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected ')', expecting variable (T_VARIABLE) or '$' in /in/7IbLJ on line 6
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected ')', expecting T_VARIABLE or '$' in /in/7IbLJ on line 6
Process exited with code 255.

preferences:
186.18 ms | 1395 KiB | 67 Q