Loading ...

Replace \\ with \ in a string ?

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  getting started / general asp.net   » Replace \\ with \ in a string ?

Replace \\ with \ in a string ?

Posts under the topic: Replace \\ with \ in a string ?

Posted: 9/3/2010

Starter 1543  points  Starter
  • Joined on: 12/22/2008
  • Posts: 46

hey hi, i want to replace \\ with \ in a string.

i m doing this

       string str = "Shaitender\\MONU".Replace("\\",@"\");
       Response.Write(str);

But in Quick watch it still showing "Shaitender\\MONU". but on the page it's showing "Shaitender\MONU".

Quick Watch Output :

Html Ouptut

Shaitender\MONU

Why both output are different any idea? i did some searching on google but still unable to figure out concept of Escape Characters

the Problem is when im passing the string it contains \\ in it . Is there any other possible way to Replace it .
Tired Regex too but still not working .

Escape characters are still mystery for me :) !!!


tags regex, Regex

Posted: 9/3/2010

Guru 16813  points  Guru
  • Joined on: 4/19/2009
  • Posts: 490
  Answered

Refer http://codeasp.net/blogs/raghav_khunger/microsoft-net/787/c-how-to-replace-double-backward-slash-with-single-backward-slash for replacement code.

Also for your second query you will always see double backward slash there where you are seeing:

You need to click the "Text Visualizer" icon in order to see the actual output:

 

 


tags c#
Page 1 of 1 (2 items)