I was using the delimiters described in this answer:
Here is shell php I'm using to demonstrate the problem:
I'm using a function on a web project that replaces a namespace syntax for a path, eg:
Warning: preg_replace(): No ending delimiter '/' found in...
You need to use
"/\\\\/" instead of
\\ will produce
\ (a single backslash) in a PHP string literal.
echo strtr($str, ['\\' => '/']);