locked
How to use c# replace function on a string with quotes and a question mark RRS feed

  • Question

  • User1868852945 posted


    In my attempt to adjust an a href string I use c# string replace function to insert the host:port into the string as below.
    original content is...
    class="col_link"style="float: left; width: 20%"><a href="?begin_parms&new_link=y&p_first_time=n
    desired content should be...
    class="col_link"style="float: left; width: 20%"><a href="localhost:64103?begin_parms&new_link=y&p_first_time=n
    Here is my replace which does not replace anything.
    myString.replace("?","localhost:64103?");

    Thanks much for any help with this 

    Saturday, February 9, 2019 3:45 PM

Answers

  • User303363814 posted

    replace() creates a new string.  You haven't shown all your code but you will need something like

    myString = myString.replace("?", whatever);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 9, 2019 9:42 PM