0

What is the easiest way, without using regex, to trim empty text elements and line breaks from a html string using c# ?

When I say trim I mean from the start and end of the html

example

input:

<br /><br /><p></p><h1>Title</h1><p></p><br /><p>paragraph</p><p></p><p></p><br />

output:

<h1>Title</h1><p></p><br/><p>paragraph</p>
Stian Standahl
  • 2,506
  • 4
  • 33
  • 43

1 Answers1

1

I am not sure, if you are looking for a tool or whatever, but I think a regular expression like this could work:

/<[^>]*><\\/[^>]*>/
Datz
  • 3,156
  • 3
  • 22
  • 50