////// Strip out html tags from text /// /// Source string ///public static string StripTagsFromHtml(string source) { return Regex.Replace(source, "<.*?>", string.Empty); }
To extract a number of characters from the source string, we can extend the function as following.
////// Strip out html tags from text and return extract from it /// /// Source string /// Number of characters to extract ///public static string StripTagsFromHtml(string source, int characterCount) { string stripped = Regex.Replace(source, "<.*?>", string.Empty); if (stripped.Length <= characterCount) return stripped; else return stripped.Substring(0, characterCount); }
Happy programming!
0 comments:
Post a Comment
Hope you liked this post. You can leave your message or you can put your valuable suggestions on this post here. Thanks for the sharing and cooperation!