Reputation: 5024
I have sample string:
$string = "муқ. - муқоиса муқ. муқ.шавад муқ томуқ.";
I try with this my code:
$result = preg_replace("/\b(муқ\.?)\b/u", 'repl', $string);
echo "$result";
Result: repl. - муқоиса repl. replшавад repl томуқ.
Needed result: repl - муқоиса repl муқ.шавад муқ томуқ.
Here I can't replace word with "." ended symbol!
Upvotes: 2
Views: 85
Reputation: 1077
You can use the str_replace function.
str_replace(".", "your word", "your string");
Upvotes: -1
Reputation: 91488
Use a negative lookahead:
$result = preg_replace("/\bмуқ\.(?!\w)/u", 'repl', $string);
Upvotes: 1
Reputation: 326
Try this:
$result = preg_replace("/\bмуқ\.\B/u", "repl", $string);
The shared link: https://regex101.com/r/zPXOtP/1
Upvotes: 4