What is wrong with this regex?

dr0gii

New Member
i need the following - if i have a sentence \[code\]$str = "i like programming very much";\[/code\]and i search for a word\[code\]$word = "r";\[/code\]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.\[code\]$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);\[/code\]Could you tell me what i wrote wrong?ThanksUPDATE:for example it doesn't work when \[code\]$str = "ameriabank"; and $word = "ab";\[/code\]...
 
Back
Top