I have this as a sample text
......
$text = "Swiss Real";
......
now what i do is this
$text = str_ireplace('swiss','<font color="red">swiss</font>',$text);
now my string is
$text is '<font color="red">swiss</font> Real'
now i want to do
$text = str_ireplace('re','<font color="red">re</font>',$text);
now here is my problem… i want to change only ‘Real’ and not the re in the ‘color=”red”‘
how do i achieve it.
please help me.
You need to use
boundary\bre\bWith
boundaryyou can match characters that are surrounded bynon-wordcharacters..Simply put it
\baround a word enables you to match an individual wordFor example for string
"Begin it in stackoverflow"and if you want to replaceinwithINinregex would replace it to"BegIN it IN stackoverflow"\bin\bregex would replace it to"Begin it IN stackoverflow"