The preg-replace is saying
OK, I’m enclosing my regex phrase with the forward slash character.
The regex engine looks for a second to end the enclosed phrase with.
Perhaps using a forward slash in the many exmples you’ll find was a bad choice.
In any case, you can either escape to make it a literal character or use a different character to enclose.
AFAIK you can use just about any character eg. if your regex had / and # in it you could use ~
IMHO its best to be consistant as much as possible - probably why all the doc examples use / - but sooner or later you’ll have one that gets messy looking with escapes and its easier to just use something different. eg.
“/<a href=\“http:\/\/domain\.com\”>/”
vs.
‘#<a href=“http://domain\.com”>#’