1

I have HTML within a string where I am trying to replace the following:

<td colspan="12" bgcolor="#460F59">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<font color="#ffffff"><b>IT  </b> 
            <b>214 </b>&#150; <font color="#FFFFFF"><b>Fund of Software Develop </b> 
            <b>&nbsp;(4 Credits)</b></font></font></td>

with:

<td colspan="12" bgcolor="#460F59">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<font color="#ffffff"><b>IT  </b> 
            <b>214 </b>&#150; <font color="#FFFFFF"><b>Fund of Software Develop </b> 
            <b>&nbsp;(4 Credits) - Prereq: IT 210</b></font></font></td>

I realize the quotations need to be fixed but how can I show that the HTML is on 3 separate lines?

Actual Code:

 s.Replace("<td colspan="12" bgcolor="#460F59">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<font color="#ffffff"><b>IT  </b> 
        <b>214 </b>&#150; <font color="#FFFFFF"><b>Fund of Software Develop </b> 
        <b>&nbsp;(4 Credits)</b></font></font></td>", "<td colspan="12" bgcolor="#460F59">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<font color="#ffffff"><b>IT  </b> 
        <b>214 </b>&#150; <font color="#FFFFFF"><b>Fund of Software Develop </b> 
        <b>&nbsp;(4 Credits) - Prereq: IT 210</b></font></font></td>");
5
  • Could you post the actual code you are using to do the replace? Commented Apr 10, 2013 at 17:43
  • 1
    Can you please clarify "It is not working"? What do you have defined as "first section" and "second section"? Commented Apr 10, 2013 at 17:44
  • 1
    The code you have posted will not compile. Are you trying to figure out how to escape " in a string? Commented Apr 10, 2013 at 17:47
  • What you want?Don't use any "" in inside of "" .Only using "''" this format .and s.replace("<td......","") Commented Apr 10, 2013 at 17:54
  • I forgot the @ in addition to """" Thanks guys Commented Apr 10, 2013 at 18:06

2 Answers 2

3

Make sure when you do a replace in C# you're assigning the output:

var s = "test";
s = s.Replace("t","b");

Otherwise s won't change.

Sign up to request clarification or add additional context in comments.

Comments

0

Why don't you just try to replace

<b>&nbsp;(4 Credits)</b></font></font></td>

with

<b>&nbsp;(4 Credits) - Prereq: IT 210</b></font></font></td>

As far as I can see, the other lines don't change at all?

1 Comment

It looks like he's trying to list a prerequisite course for the course bing listed. I imagine he probably needs to replace based on the value of "<b>IT </b><b>214 </b>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.