preg_replace
模式用/
或&
替换为and
有无空格?该模式应该能够取代以下所有示例:
This is J/J.
到This is J and J.
。
J/J, Y& S, and U / A are names.
到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?
答案 0 :(得分:1)
试试这个:
<?php
$text = "J/J, Y& S, and U / A are names.";
$result = preg_replace('~[/&]~', ' and ', $text, -1);
echo $result;