Strip out HTML tags using RegEx

This code will strip out all the HTML tags and truncate the text to 4 lines.

public static string TruncateText(string txtIn, int newLength)
{
    string txtOut = txtIn;
    string pattern = @"<(.|\n)*?>";

    //Strip out HTML tags
    if (Regex.IsMatch(txtIn, pattern, RegexOptions.None))
        txtOut = Regex.Replace(txtIn, pattern, string.Empty, RegexOptions.Multiline).Trim();

    if (txtOut.Length > newLength)
    {
        int endPos = txtOut.LastIndexOf(" ", newLength);
        txtOut = txtOut.Substring(0, endPos) + "...";
    }

    return txtOut;
}
If you have any questions or comments, please post them below. If you liked this post, you can share it with your followers or follow me on Twitter!