Saturday, May 30, 2009

Strip HTML Tags From a String

// Strip HTML Tags From a String

string strippedString = Regex.Replace(htmlString,@"<(.|\n)*?>",string.Empty);

/*
This will strip anything found in HTML tags.
(.|\n) -- Finds any character including the new line character
*? -- 0 or more occurences and the match will stop at the first
occuring ">" it sees
*/

No comments:

Post a Comment