using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;

public static class Helper
{

    public static string StripHTML(this string htmlText)
    {
        var reg = new Regex("<[^>]+>", RegexOptions.IgnoreCase);

        return HttpUtility.HtmlDecode(reg.Replace(htmlText, string.Empty));
    }

    public static string FormatResults(this string text, string search)
    {
        int start = text.ToLower().IndexOf(search.ToLower());
        int n;
        n = (start + 80 > text.Length) ? (text.Length - start - 1) : 80;

        return text.Substring(Math.Max(start, 0), Math.Min(n, text.Length - start)) + "...";

    }
}