I have the following string:
$text="א אב אבי אביהו מדינה שול של";
In which I wish to add 'אאא' to all <4 chars word, so the string will turn into:
"אאאא אבאאא אביאאא אביהו מדינה שולאאא שלאאא"
The code I am using is:
$text="א אב אבי אביהו מדינה שול של";
$pattern='/\s(.{1,6})\s/';
$text=preg_replace($pattern,' $1אאא ',$text);
echo $text;
Which results in:
א אבאאא אבי אביהו מדינה שולאאא של
Problems:
1. It seems word boundry is not recognized (hence my use of \s).
2. Why was the אבי not replaced?