i need the following -
if i have a sentence
$str = "i like programming very much";
and i search for a word
$word = "r";
i expect it to return the sentence
"i like programing very much"
I wrote the following regex for it, but it sometimes doesn't work.
$str = preg_replace("/([^\s{".preg_quote($word)."}]*?)(".preg_quote($word).")([^\s{".preg_quote($word)."}]*)/siu","<span class='pice1'>$1</span><span class='pice2'>$2</span><span class='pice1'>$3</span>",$str);
Could you tell me what i wrote wrong?
Thanks
UPDATE:
for example it doesn't work when
$str = "ameriabank"; and $word = "ab";
...