I want to match any instance of [space][slash][space].
ie.
" / "
in a regex pattern.
I can’t find the answer anywhere. What have I missed?
function madeby_remove_slash($text) {
preg_replace('/ \/ /', ' ', $text);
return $text;
}
echo madeby_remove_slash('This is the / text');
You don’t assign the return value of the preg_replace to the
$textvariable in your function.or if you want to replace a literal string you can use str_replace too.