用有空格和不带空格的and
代替/
或&
的preg_replace
模式是什么?该模式应该能够替换以下所有示例:
This is J/J.
to This is J and J.
。
J/J, Y& S, and U / A are names.
to J and J, Y and S and U and A are names.
。
What does J /J or J & E mean?
到What does J and J or J and E mean?
试试这个:
<?php
$text = "J/J, Y& S, and U / A are names.";
$result = preg_replace('~[/&]~', ' and ', $text, -1);
echo $result;