How can I strip all html tags except <br> in C# code?
c#, html, regex
Solution
Try this regex
return Regex.Replace(text, @”<(?!br[\x20/>])[^<>]+>”, string.Empty);
But I think a html parser might work better with these tasks.
Problem
What I want to do is to remove all html tags except `<br>` tags. I have made an example: ``` public string Strip(string text) { return Regex.Replace(text, @”<(.|\n)*?>”, string.Empty); } ``` But this one removes all. Any kind of help is appreciated.