SamJolly
SamJolly

Reputation: 6477

How to replace this HTML snippet in some text?

I am using ASP.NET 4.5 and C#

I want to replace :

<div style="page-break-after:always"><span style="display:none">&nbsp;</span></div>

in a string with:

<br style="page-break-after: always;" />

I have tried:

//string strContent is a string that contains HTML content
strContent = strContent.Replace("<div style='page-break-after:always'><span style='display:none'>&nbsp;</span></div>", "<br style='page-break-after: always;' />"); 

But with no success. Obviously I am missing something simple.

Help hugely appreciated.

Upvotes: 0

Views: 206

Answers (1)

Christoph Fink
Christoph Fink

Reputation: 23103

You mixed up the " and ':

strContent = strContent
    .Replace("<div style=\"page-break-after:always\">" + 
             "<span style=\"display:none\">&nbsp;</span></div>",
             "<br style=\"page-break-after: always;\" />");

Upvotes: 2

Related Questions