Geekpedia Forums Logo

C# problem. Replacing \

by joe sparshott on Thursday, November 29th - 9:32 AM



been trying for ages to get it to recognize it as a character and not a function.
here is the code i have at the moment:

string a;
a = textBox2.Text;
a = Regex.Replace("\", "/");

but it dosent end the String at the quotation marks.
this is what it takes the string as:
"\", "
it totally ignoes the \ and the second "
any advice. thanks.

Try this:

a = Regex.Replace(@"\", "/");

Or the old double slash technique:

a = Regex.Replace(@"\\", "/");