Just use
" " + str + " "
in place of str so that the 'str' only with space is replaced.
You have to use the code like this:
if (Regex.IsMatch(retext, string.Format(@"\b{0}\b";, str, RegexOptions.Singleline)) == true)
{
Label3.Text = retext.Replace(" " + str + " ", string.Format("<span style="font-weight">
bold;background-color:yellow ;'> {0,1}</span>", " " + str + " "));
string strdis = retext.Replace(" " + str + " ", string.Format("", " " + str + " "), RegexOptions.Singleline
RegexOptions.IgnoreCase);
retext = Label3.Text;
}
Thanks