Html.Encode和包含html代码段的字符串

| 我正在尝试在某些文本中突出显示搜索结果。我写了一个扩展方法:
public static string Highlight(this HtmlHelper html, string input, string searchPhrase)
{
    Regex.Replace(input, 
                  \"\\\\b\" + searchPhrase + \"\\\\b\", 
                  \"<strong>\" + searchPhrase + \"</strong>\", 
                  RegexOptions.IgnoreCase);
}
但是很明显,当它是Html.View编码时,html标记只是作为文本的一部分呈现。 有更好的方法吗?或者,如果我的想法还可以,我如何使它起作用?     
已邀请:
public static MvcHtmlString Highlight(this HtmlHelper html, string input, string searchPhrase)
{
    var value = Regex.Replace(
        input, 
        \"\\\\b\" + searchPhrase + \"\\\\b\", 
        \"<strong>\" + searchPhrase + \"</strong>\", 
        RegexOptions.IgnoreCase
    );
    return MvcHtmlString.Create(value);
}
并在视图中:
@Html.Highlight(\"foo\", \"f\")
    

要回复问题请先登录注册