c# - Removing empty paragraph tags -


i find simplest way trim empty

tags before text starts. example have below text.

<p> </p><p> </p> <p> </p><p>     </p> <p>    </p> <p>this example<br></p><p> </p><p>continue </p> 

i output <p>this example<br></p><p> </p><p>continue </p>

i want empty p tags removed. there can more 1 space between

tags.

i have options use css or vb or c#.

give comment, accept c# i'd suggest using simple regular expression validate this:

var source = @"<p> </p><p> </p> <p> </p><p>     </p> <p>    </p> <p>this example<br></p><p> </p><p>continue </p>";  string output = regex.replace(source, @"<p>\s*</p>", "").trim(); 

the same code in vb.net converted telerik should this:

dim source = "<p> </p><p> </p>" & vbcr & vblf & "<p> </p><p>     </p>" & vbcr & vblf & "<p>    </p>" & vbcr & vblf & "<p>this example<br></p><p> </p><p>continue </p>"  dim output string = regex.replace(source, "<p>\s*</p>", "").trim() 

explanation:

<p> matches characters <p> literally \s* match white space character [\r\n\t\f ] 0 unlimited times </p> matches characters </p> literally 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -