Last active
August 29, 2015 14:07
-
-
Save pabloprogramador/1c31bb01469b1c831f15 to your computer and use it in GitHub Desktop.
StripTags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@helper StripTags(string conteudo, int quantidade = 0){ | |
string noHTML = System.Text.RegularExpressions.Regex.Replace(conteudo, @"<[^>]+>| ", "").Trim(); | |
noHTML = System.Web.HttpUtility.HtmlDecode(noHTML); | |
if(quantidade > 0){ | |
noHTML = noHTML.Substring(0, quantidade > noHTML.Length ? noHTML.Length : quantidade); | |
} | |
@System.Web.HttpUtility.HtmlDecode(noHTML) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment