<asp:textbox rows="10" columns="30" textmode="MultiLine" id="txtSearch" runat="server" text="When implementing some software for another project, I came across several requirements involving calculations with time periods. These calculations were an important part of the solution and had high demands in respect to the correctness and accuracy of the results." xmlns:asp="#unknown"></asp:textbox>
<asp:label id="lmsg" runat="server" xmlns:asp="#unknown"></asp:label>
<asp:button id="btnSearch" runat="server" text="Search" onclick="btnSearch_Click" xmlns:asp="#unknown" />
protected void btnSearch_Click(object sender, EventArgs e)
{
lmsg.Text = HighlightFont(txtSearch.Text, "implementing");
}
protected static string HighlightFont(string Search_Str, string InputTxt)
{
if (InputTxt != "" && (Search_Str.ToLower().IndexOf(InputTxt) != -1))
{
var dictionary = new Dictionary
{
{InputTxt,"" + InputTxt + ""}
};
var regex = "(" + String.Join(")|(", dictionary.Keys.ToArray()) + ")";
foreach (Match metamatch in Regex.Matches(Search_Str, regex, RegexOptions.IgnoreCase))
{
Search_Str = Search_Str.Replace(metamatch.Value, dictionary[metamatch.Value.ToLower()]);
}
return Search_Str;
}
else
{
return Search_Str;
}
}