我有样本字符串:
$string = "муқ. - муқоиса муқ. муқ.шавад муқ томуқ.";
我试着用我的代码:
$result = preg_replace("/\b(муқ\.?)\b/u", 'repl', $string);
echo "$result";
结果:repl。 - 比较repl。替换更换
需要的结果:将比较替换为另一个。
在这里,我无法用“。”代替单词。结束了符号!
使用否定前瞻:
$result = preg_replace("/\bмуқ\.(?!\w)/u", 'repl', $string);
您可以使用str_replace函数。
str_replace(".", "your word", "your string");