replace function for spcial charecters in c#

Rate It (1)

Last post 11-21-2007 1:47 AM by ram_krish86. 1 replies.

Sort Posts:

  • replace function for spcial charecters in c#

    11-21-2007, 1:23 AM
    • Loading...
    • ram_krish86
    • Joined on 11-06-2007, 12:54 AM
    • Hyderabad
    • Posts 57

    hi guys

    pls help me out!

    i have an issue with replace function.,
     
    when i enter some text in a textbox as "TEXT+BOX " the function must replace the "+" charecter as "_"
    this is   what i have written for a replace function  
    String myString =txt_Asset.Text;
                myString = Regex.Replace(myString, " ", "_");
                myString = Regex.Replace(myString, "+", "_");

     

    the first one is working fine.,

    but             myString = Regex.Replace(myStr ing, "+", "_");  this one is giving an error.,

     

    how to replace spcial charecters in c# using replace function??

    Ramakrishna.N
  • Re: replace function for spcial charecters in c#

    11-21-2007, 1:47 AM
    Answer
    • Loading...
    • ram_krish86
    • Joined on 11-06-2007, 12:54 AM
    • Hyderabad
    • Posts 57

    ok ok

    got it

    myString = Regex.Replace(myString,Regex.Escape("+"), "_");

    this worked for me.,

     

    Ramakrishna.N
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter