locked
Replace word with quoets RRS feed

  • Question

  • User-375223641 posted

    I want to replace this statement<span class="xxx"> with <span class="CCC"> I don't know how to do it becasue of the double quoets.
    Thanks 

    Tuesday, August 20, 2013 3:26 PM

Answers

  • User-760709272 posted
    yourString = yourString.Replace("<span class=\"xxx\">", "<span class=\"CCC">\");

    You just replace the quotes inside your params with \"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 20, 2013 3:28 PM
  • User281315223 posted

    You would just need to escape the quotes using a slash and the String.Replace() method as seen below : 

    var currentString = currentString.Replace("<span class=\"xxx\">", "<span class=\"CCC\">");

    Within Visual Studio "\"" is going to be equivalent to a single double-quote within your string.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 20, 2013 4:14 PM

All replies

  • User-760709272 posted
    yourString = yourString.Replace("<span class=\"xxx\">", "<span class=\"CCC">\");

    You just replace the quotes inside your params with \"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 20, 2013 3:28 PM
  • User281315223 posted

    You would just need to escape the quotes using a slash and the String.Replace() method as seen below : 

    var currentString = currentString.Replace("<span class=\"xxx\">", "<span class=\"CCC\">");

    Within Visual Studio "\"" is going to be equivalent to a single double-quote within your string.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 20, 2013 4:14 PM
  • User-760709272 posted

    Good to see my new signature is working well for me already Innocent

    Tuesday, August 20, 2013 5:15 PM
  • User-1910946339 posted

    Good to see my new signature is working well for me already Innocent

    Not by much, but ... your answer wasn't right.  It wouldn't compile. You escaped the wrong double quote at the end of the string.

    Wednesday, August 21, 2013 12:29 AM
  • User-760709272 posted

    Fair play this time :) But Rion (others too, not just him) has a habit of replying to threads where the answer has already been given just to give the same answer.  Three instances come to mind in recent weeks where this has happened.  Sometimes the OP marks all answers, sometimes the first answer and sometimes the last.  I just don't understand why you answer a thread where the answer has already been given.

    Wednesday, August 21, 2013 4:08 AM
  • User281315223 posted

    I usually try to post answers within a thread if I feel I can contribute something that hadn't been mentioned (especially if I feel that it helps clarify what the problem or fix is). However, a majority of the time, I have multiple tabs open with different answers that I add to as time permits throughout the day (which can often result in my answers appearing much later than they probably should).

    I'm not trying to do it out of spite or with any ill intentions, I'm just trying to help someone out (just as you are). I'll work on refreshing the threads within a new tab prior to submitting an answer, which should hopefully help resolve some of these issues, but there will no doubt still be cases when very similar answers are posted.

    As far as OP choosing threads as answers, I usually try to PM new members and make them aware of the ability to select multiple answers as "Answer". I even sent one within this thread after my answer was selected, notifying the OP of your answer and that it was "correct" in a sense that it contained a typo but the actual logic was there and encouraged them to mark it as well.

    Wednesday, August 21, 2013 8:22 AM