In some cases, we need to get part of a block of HTML contents, if truncate it directly, the HTML tags will be truncated, too.

So before truncating, we have to remove all the HTML tags in the content.

The following JavaScript codes is used to remove HTML tags from a block of HTML codes:

function RemoveHTML( strText )

{

var regEx = /<[^>]*>/g;

return strText.replace(regEx, "");

}

the following is the C# codes to remove HTML tags:

        private string RemoveHTMLInServer(string in_HTML)
        {
            return Regex.Replace(in_HTML, "<(.|\n)*?>", "");
        }

posted on   今夜太冷  阅读(425)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示