Why does the 2nd case not make the replacement? Isn't '}' a non-word character? Including the forward slash is necessary in the original code that I was working on.
// Works
$s = 'abc/stringToReplace-ABC';
$pattern = '/\b\/stringToReplace\b/';
$s2 = preg_replace($pattern, '/-replacement', $s);
echo $s2 . PHP_EOL; // output: abc/-replacement-ABC
// Doesn't work.
$s = 'abc}/stringToReplace-ABC';
$pattern = '/\b\/stringToReplace\b/';
$s2 = preg_replace($pattern, '/-replacement', $s);
echo $s2 . PHP_EOL; // output: abc}/stringToReplace-ABC