Reputation: 10139
I want to remove a backslash character from this string:
String result = "[{\"venues\":{\"venueId\":1,\"name\":\"First Venue\","
+ "\"telephone\":\"jkljl\",\"description\":\"Edited Description\","
+ "\"address\":\"jlkjlj\",\"city\":\"lkjl\",\"postcode\":\"M221TX\","
+ "\"image\":z\"abcImage007.jpg\",\"latitude\":53.37655,\"longitude\":-2.27418,\"deleted\":0,"
+ "\"events\":[{\"eventId\":3,\"name\":\"Test Event\",\"description\":\"Test Event Description\",\"date\":\"24/07/2011\",\"startTime\":\"11:11\",\"venueId\":0,\"deleted\":1},"
+ "{\"eventId\":3,\"name\":\"Test Event\",\"description\":\"Test Event Description\",\"date\":\"25/07/2011\",\"startTime\":\"11:11\",\"venueId\":0,\"deleted\":1}]}}]";
I have tried:
String abc = result.Replace(@"\",@"");
String abc = result.Replace(@"\",string.Empty);
String abc = result.Replace(@"\\",@"");
String abc = result.Replace(@"\\",string.Empty);
But nothing is working. Could someone help please.
Thanks
Upvotes: 7
Views: 20424
Reputation: 1
test this code
String abc = result[0].Replace(@"\",@"");
String abc = result[0].Replace(@"\",string.Empty);
String abc = result[0].Replace(@"\\",@"");
String abc = result[0].Replace(@"\\",string.Empty).
Upvotes: -1
Reputation: 41569
More fully:
Your string doesn't contain the \ character. In the variable declaration it is used to escape the " character so that it can be put into the string without causing the end of the string to occur.
If write out the value of the variable somewhere you'll find there are no \ characters
Upvotes: 1
Reputation: 11820
you dont need to remove them. \" is escape sequence that shows that in your string is " symbol(quotation mark)
Upvotes: 2