The reason is that the word boundary coincides in the following positions:
- Before the first character in a string, if the first character is a word character.
- After the last character in a string, if the last character is a character in a word.
- , , .
"" U+0670 ARABIC LETTER SUPERSCRIPT ALEF \p{Mn} ( Unicode) , , . \b , char, \w (, , _).
, / :
$str = 'کس نے موسیٰ کے بارے میں سنا ہے؟';
$str = preg_replace('/(?<!\w)موسیٰ(?!\w)/u', 'Musa', $str);
$str = preg_replace('/(?<!\w)سنا(?!\w)/u', 'suna', $str);
echo $str;
- PHP.
(?<!\w) - lookbehind, , char , (?!\w) - , , char .